-
Notifications
You must be signed in to change notification settings - Fork 71
Description
TL;DR
I have a workflow set up to publish a function, which works successfully -if the function does not already exist. If the function does exist (e.g. from a previous run of the Action), then the update fails.
Expected behavior
New updates to function code are published as new versions of the existing Function in GCP.
Observed behavior
The job fails with:
"error": ***
"code": 409,
"message": "Function send_slack_chat_notification in region us-east1 in project <my_project> already exists",
"status": "ALREADY_EXISTS"
***
***
### Action YAML
```yaml
jobs:
update_function:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v3
- id: auth
uses: google-github-actions/auth@v0
with:
credentials_json: '${{ secrets.GCP_KEY }}'
- id: 'deploy'
uses: 'google-github-actions/deploy-cloud-functions@v0.10.1'
with:
name: 'send_slack_chat_notification'
event_trigger_type: providers/cloud.pubsub/eventTypes/topic.publish
event_trigger_resource: projects/<my_project>/topics/scc-notifications
project_id: <my_project>
region: 'us-east1'
runtime: 'python38'
secret_environment_variables: 'SCCSECRET=<secret_path>'
source_dir: <path/to/src>
timeout: 15
min_instances: 0
max_instances: 3
Log output
2022-07-27T21:43:17.8082442Z Requested labels: ubuntu-latest
2022-07-27T21:43:17.8082490Z Job defined at: <my_org>/security-scripts/.github/workflows/slack-chat-high-and-critical-findings.yml@refs/heads/master
2022-07-27T21:43:17.8082506Z Waiting for a runner to pick up this job...
2022-07-27T21:43:18.4018233Z Job is waiting for a hosted runner to come online.
2022-07-27T21:43:23.3100474Z Job is about to start running on the hosted runner: Hosted Agent (hosted)
2022-07-27T21:43:27.5402127Z Current runner version: '2.294.0'
2022-07-27T21:43:27.5438261Z ##[group]Operating System
2022-07-27T21:43:27.5439270Z Ubuntu
2022-07-27T21:43:27.5439789Z 20.04.4
2022-07-27T21:43:27.5440352Z LTS
2022-07-27T21:43:27.5440871Z ##[endgroup]
2022-07-27T21:43:27.5441431Z ##[group]Virtual Environment
2022-07-27T21:43:27.5442084Z Environment: ubuntu-20.04
2022-07-27T21:43:27.5442671Z Version: 20220724.1
2022-07-27T21:43:27.5443573Z Included Software: https://github.com/actions/virtual-environments/blob/ubuntu20/20220724.1/images/linux/Ubuntu2004-Readme.md
2022-07-27T21:43:27.5444573Z Image Release: https://github.com/actions/virtual-environments/releases/tag/ubuntu20%2F20220724.1
2022-07-27T21:43:27.5445305Z ##[endgroup]
2022-07-27T21:43:27.5445924Z ##[group]Virtual Environment Provisioner
2022-07-27T21:43:27.5446546Z 1.0.0.0-main-20220701-2
2022-07-27T21:43:27.5447094Z ##[endgroup]
2022-07-27T21:43:27.5448303Z ##[group]GITHUB_TOKEN Permissions
2022-07-27T21:43:27.5449173Z Contents: read
2022-07-27T21:43:27.5449987Z Metadata: read
2022-07-27T21:43:27.5450614Z ##[endgroup]
2022-07-27T21:43:27.5455343Z Secret source: Actions
2022-07-27T21:43:27.5456114Z Prepare workflow directory
2022-07-27T21:43:27.6492955Z Prepare all required actions
2022-07-27T21:43:27.6721990Z Getting action download info
2022-07-27T21:43:27.8979958Z Download action repository 'actions/checkout@v3' (SHA:2541b1294d2704b0964813337f33b291d3f8596b)
2022-07-27T21:43:28.6254956Z Download action repository 'google-github-actions/auth@v0' (SHA:ceee102ec2387dd9e844e01b530ccd4ec87ce955)
2022-07-27T21:43:29.0487853Z Download action repository 'google-github-actions/deploy-cloud-functions@v0.10.1' (SHA:150007aacd86ec18da039413072dc179aa95bc16)
2022-07-27T21:43:29.8277579Z ##[group]Run actions/checkout@v3
2022-07-27T21:43:29.8278322Z with:
2022-07-27T21:43:29.8278830Z repository: <my_org>/security-scripts
2022-07-27T21:43:29.8279670Z token: ***
2022-07-27T21:43:29.8280172Z ssh-strict: true
2022-07-27T21:43:29.8280664Z persist-credentials: true
2022-07-27T21:43:29.8281415Z clean: true
2022-07-27T21:43:29.8281876Z fetch-depth: 1
2022-07-27T21:43:29.8282322Z lfs: false
2022-07-27T21:43:29.8282852Z submodules: false
2022-07-27T21:43:29.8283357Z set-safe-directory: true
2022-07-27T21:43:29.8283948Z ##[endgroup]
2022-07-27T21:43:30.1903540Z Syncing repository: <my_org>/security-scripts
2022-07-27T21:43:30.1906419Z ##[group]Getting Git version info
2022-07-27T21:43:30.1907343Z Working directory is '/home/runner/work/security-scripts/security-scripts'
2022-07-27T21:43:30.1908450Z [command]/usr/bin/git version
2022-07-27T21:43:30.2034006Z git version 2.37.1
2022-07-27T21:43:30.2057462Z ##[endgroup]
2022-07-27T21:43:30.2085557Z Temporarily overriding HOME='/home/runner/work/_temp/d2da96fe-3813-48b3-8270-e05943cc6836' before making global git config changes
2022-07-27T21:43:30.2086397Z Adding repository directory to the temporary git global config as a safe directory
2022-07-27T21:43:30.2087455Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/security-scripts/security-scripts
2022-07-27T21:43:30.2161948Z Deleting the contents of '/home/runner/work/security-scripts/security-scripts'
2022-07-27T21:43:30.2168996Z ##[group]Initializing the repository
2022-07-27T21:43:30.2173878Z [command]/usr/bin/git init /home/runner/work/security-scripts/security-scripts
2022-07-27T21:43:30.2256191Z hint: Using 'master' as the name for the initial branch. This default branch name
2022-07-27T21:43:30.2257520Z hint: is subject to change. To configure the initial branch name to use in all
2022-07-27T21:43:30.2258785Z hint: of your new repositories, which will suppress this warning, call:
2022-07-27T21:43:30.2259400Z hint:
2022-07-27T21:43:30.2260244Z hint: git config --global init.defaultBranch <name>
2022-07-27T21:43:30.2260891Z hint:
2022-07-27T21:43:30.2261591Z hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
2022-07-27T21:43:30.2262386Z hint: 'development'. The just-created branch can be renamed via this command:
2022-07-27T21:43:30.2263333Z hint:
2022-07-27T21:43:30.2263875Z hint: git branch -m <name>
2022-07-27T21:43:30.2270990Z Initialized empty Git repository in /home/runner/work/security-scripts/security-scripts/.git/
2022-07-27T21:43:30.2285929Z [command]/usr/bin/git remote add origin https://github.com/<my_org>/security-scripts
2022-07-27T21:43:30.2344487Z ##[endgroup]
2022-07-27T21:43:30.2345806Z ##[group]Disabling automatic garbage collection
2022-07-27T21:43:30.2350328Z [command]/usr/bin/git config --local gc.auto 0
2022-07-27T21:43:30.2388333Z ##[endgroup]
2022-07-27T21:43:30.2389852Z ##[group]Setting up auth
2022-07-27T21:43:30.2399486Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2022-07-27T21:43:30.2454945Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2022-07-27T21:43:30.2920268Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2022-07-27T21:43:30.3089924Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2022-07-27T21:43:30.3229988Z [command]/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2022-07-27T21:43:30.3278581Z ##[endgroup]
2022-07-27T21:43:30.3279867Z ##[group]Fetching the repository
2022-07-27T21:43:30.3289552Z [command]/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +1ec3cf49247b9b38c74611f22757e1aa23d45216:refs/remotes/origin/master
2022-07-27T21:43:30.7197987Z remote: Enumerating objects: 10, done.
2022-07-27T21:43:30.7301154Z remote: Counting objects: 10% (1/10)
2022-07-27T21:43:30.7301655Z remote: Counting objects: 20% (2/10)
2022-07-27T21:43:30.7302097Z remote: Counting objects: 30% (3/10)
2022-07-27T21:43:30.7302545Z remote: Counting objects: 40% (4/10)
2022-07-27T21:43:30.7302976Z remote: Counting objects: 50% (5/10)
2022-07-27T21:43:30.7303405Z remote: Counting objects: 60% (6/10)
2022-07-27T21:43:30.7303829Z remote: Counting objects: 70% (7/10)
2022-07-27T21:43:30.7304269Z remote: Counting objects: 80% (8/10)
2022-07-27T21:43:30.7304695Z remote: Counting objects: 90% (9/10)
2022-07-27T21:43:30.7305121Z remote: Counting objects: 100% (10/10)
2022-07-27T21:43:30.7305566Z remote: Counting objects: 100% (10/10), done.
2022-07-27T21:43:30.7306027Z remote: Compressing objects: 14% (1/7)
2022-07-27T21:43:30.7306477Z remote: Compressing objects: 28% (2/7)
2022-07-27T21:43:30.7306916Z remote: Compressing objects: 42% (3/7)
2022-07-27T21:43:30.7307349Z remote: Compressing objects: 57% (4/7)
2022-07-27T21:43:30.7307780Z remote: Compressing objects: 71% (5/7)
2022-07-27T21:43:30.7308213Z remote: Compressing objects: 85% (6/7)
2022-07-27T21:43:30.7308642Z remote: Compressing objects: 100% (7/7)
2022-07-27T21:43:30.7309089Z remote: Compressing objects: 100% (7/7), done.
2022-07-27T21:43:30.7309920Z remote: Total 10 (delta 0), reused 8 (delta 0), pack-reused 0
2022-07-27T21:43:30.7362539Z From https://github.com/<my_org>/security-scripts
2022-07-27T21:43:30.7363464Z * [new ref] 1ec3cf49247b9b38c74611f22757e1aa23d45216 -> origin/master
2022-07-27T21:43:30.7422136Z ##[endgroup]
2022-07-27T21:43:30.7425476Z ##[group]Determining the checkout info
2022-07-27T21:43:30.7427185Z ##[endgroup]
2022-07-27T21:43:30.7430302Z ##[group]Checking out the ref
2022-07-27T21:43:30.7432118Z [command]/usr/bin/git checkout --progress --force -B master refs/remotes/origin/master
2022-07-27T21:43:30.7475698Z Reset branch 'master'
2022-07-27T21:43:30.7476840Z branch 'master' set up to track 'origin/master'.
2022-07-27T21:43:30.7487483Z ##[endgroup]
2022-07-27T21:43:30.7539394Z [command]/usr/bin/git log -1 --format='%H'
2022-07-27T21:43:30.7575711Z '1ec3cf49247b9b38c74611f22757e1aa23d45216'
2022-07-27T21:43:30.8075784Z ##[group]Run google-github-actions/auth@v0
2022-07-27T21:43:30.8076454Z with:
2022-07-27T21:43:30.8082387Z credentials_json: ***
2022-07-27T21:43:30.8082789Z create_credentials_file: true
2022-07-27T21:43:30.8083202Z export_environment_variables: true
2022-07-27T21:43:30.8083611Z cleanup_credentials: true
2022-07-27T21:43:30.8084002Z access_token_lifetime: 3600s
2022-07-27T21:43:30.8084508Z access_token_scopes: https://www.googleapis.com/auth/cloud-platform
2022-07-27T21:43:30.8084976Z retries: 0
2022-07-27T21:43:30.8085333Z id_token_include_email: false
2022-07-27T21:43:30.8085706Z ##[endgroup]
2022-07-27T21:43:30.9001949Z Created credentials file at "/home/runner/work/security-scripts/security-scripts/gha-creds-b8959e0fd8a1e019.json"
2022-07-27T21:43:30.9004227Z
2022-07-27T21:43:30.9043521Z
2022-07-27T21:43:30.9212790Z ##[group]Run google-github-actions/deploy-cloud-functions@v0.10.1
2022-07-27T21:43:30.9213864Z with:
2022-07-27T21:43:30.9214220Z name: send_slack_chat_notification
2022-07-27T21:43:30.9214725Z event_trigger_type: providers/cloud.pubsub/eventTypes/topic.publish
2022-07-27T21:43:30.9215338Z event_trigger_resource: projects/<my_project>/topics/scc-notifications
2022-07-27T21:43:30.9215875Z project_id: <my_project>
2022-07-27T21:43:30.9216511Z region: us-east1
2022-07-27T21:43:30.9216853Z runtime: python38
2022-07-27T21:43:30.9217340Z secret_environment_variables: SCCSECRET=<secret_path>
2022-07-27T21:43:30.9217958Z source_dir: <my_project>/slack-chat-high-and-critical-findings
2022-07-27T21:43:30.9218427Z timeout: 60s
2022-07-27T21:43:30.9218821Z https_trigger_security_level: security_level_unspecified
2022-07-27T21:43:30.9219237Z event_trigger_retry: false
2022-07-27T21:43:30.9219624Z deploy_timeout: 300
2022-07-27T21:43:30.9220087Z env:
2022-07-27T21:43:30.9220753Z CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE: /home/runner/work/security-scripts/security-scripts/gha-creds-b8959e0fd8a1e019.json
2022-07-27T21:43:30.9221513Z GOOGLE_APPLICATION_CREDENTIALS: /home/runner/work/security-scripts/security-scripts/gha-creds-b8959e0fd8a1e019.json
2022-07-27T21:43:30.9222238Z GOOGLE_GHA_CREDS_PATH: /home/runner/work/security-scripts/security-scripts/gha-creds-b8959e0fd8a1e019.json
2022-07-27T21:43:30.9222818Z CLOUDSDK_CORE_PROJECT: <my_project>
2022-07-27T21:43:30.9223293Z CLOUDSDK_PROJECT: <my_project>
2022-07-27T21:43:30.9223745Z GCLOUD_PROJECT: <my_project>
2022-07-27T21:43:30.9224186Z GCP_PROJECT: <my_project>
2022-07-27T21:43:30.9224644Z GOOGLE_CLOUD_PROJECT: <my_project>
2022-07-27T21:43:30.9225056Z ##[endgroup]
2022-07-27T21:43:31.1443882Z Created zip file from '<my_project>/slack-chat-high-and-critical-findings' at '/tmp/cfsrc-6417ed11adfe01c6ef8a6252.zip'
2022-07-27T21:43:33.3925726Z Creating new Cloud Function deployment
2022-07-27T21:43:34.6129494Z ##[error]google-github-actions/deploy-cloud-functions failed with: failed to POST https://cloudfunctions.googleapis.com/v1/projects/<my_project>/locations/us-east1/functions: (409) ***
"error": ***
"code": 409,
"message": "Function send_slack_chat_notification in region us-east1 in project <my_project> already exists",
"status": "ALREADY_EXISTS"
***
***
2022-07-27T21:43:34.6228582Z Post job cleanup.
2022-07-27T21:43:34.7024927Z Removed exported credentials at "/home/runner/work/security-scripts/security-scripts/gha-creds-b8959e0fd8a1e019.json".
2022-07-27T21:43:34.7127667Z Post job cleanup.
2022-07-27T21:43:34.8620249Z [command]/usr/bin/git version
2022-07-27T21:43:34.8679446Z git version 2.37.1
2022-07-27T21:43:34.8747547Z Temporarily overriding HOME='/home/runner/work/_temp/25c8ba1d-6de6-4263-b2ce-72aee82e0139' before making global git config changes
2022-07-27T21:43:34.8749097Z Adding repository directory to the temporary git global config as a safe directory
2022-07-27T21:43:34.8755525Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/security-scripts/security-scripts
2022-07-27T21:43:34.8800097Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2022-07-27T21:43:34.8846223Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2022-07-27T21:43:34.9118819Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2022-07-27T21:43:34.9150532Z http.https://github.com/.extraheader
2022-07-27T21:43:34.9164479Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2022-07-27T21:43:34.9206063Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2022-07-27T21:43:34.9774243Z Cleaning up orphan processes
Additional information
I've tried as many variations of the workflow config as I can think of, though none of them appear to be targeted towards controlling updates vs. create behavior, and I don't otherwise see how I can influence which method the Action is using.
This originally failed for me when trying to update a manually-created function, so I deleted that one entirely. I then ran the Action to create the function from scratch, and then attempted to update that deployment via subsequent runs of the Action, with no success.