google-github-actions / deploy-cloudrun

A GitHub Action for deploying services to Google Cloud Run.
https://cloud.google.com/run
Apache License 2.0
467 stars 115 forks source link

revision tags are messed up #529

Closed xSAVIKx closed 3 months ago

xSAVIKx commented 4 months ago

TL;DR

latest and other tags are applied to recently deployed revision even when tag is set to a specific value and no-traffic is used.

image

prod tag should have stayed at the previous revision where 100% of traffic is

wf-logs.txt

Expected behavior

Only the specified tag is added

Observed behavior

all tags from the previous "latest" are moved to the newly deployed revision

Action YAML

name: Deploy Feature Branch

on:
  pull_request:
    types: [ labeled ]
  workflow_dispatch:

concurrency:
  group:
    ${{ github.repository }}-${{ github.workflow }}-${{ github.event.number || github.head_ref || github.run_id || github.sha }}
  cancel-in-progress: true
env:
  POETRY_VERSION: "1.8.2"
  POETRY_EXPORT_PLUGIN_VERSION: "1.7.1"
  PYTHON_VERSION: "3.11.9"
  GCP_REGION: "europe-west2"

jobs:
  deploy-container:
    if: |
      github.event_name == 'workflow_dispatch'
      || (github.event_name == 'pull_request' && github.event.label.name == 'deploy')
    runs-on: ubuntu-22.04
    outputs:
      image: ${{ steps.deploy-container.outputs.image }}
      image_sha: ${{ steps.deploy-container.outputs.image_sha }}
      image_sha_short: ${{ steps.deploy-container.outputs.image_sha_short }}
      image_version: ${{ steps.deploy-container.outputs.image_version }}
      service_url: ${{ steps.deploy.outputs.url }}
    steps:
      - uses: actions/checkout@v4
      - name: "Authenticate GCP"
        uses: "./.github/actions/auth-gcp"
        with:
          GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
          GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
          GCP_REGION: ${{ env.GCP_REGION }}
      - uses: "./.github/actions/deploy-custom-container"
        id: "deploy-container"
        with:
          containerName: "${{ env.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker-registry/<SERVICE_NAME>"
          dockerfileName: "Dockerfile"
          tag: "fb-${{ github.event.number || github.run_id }}"
      - uses: "google-github-actions/deploy-cloudrun@v2"
        id: "deploy"
        with:
          service: "<SERVICE_NAME>"
          image: "${{ steps.deploy-container.outputs.image }}"
          project_id: ${{ secrets.GCP_PROJECT_ID }}
          region: ${{ env.GCP_REGION }}
          timeout: 6s
          tag: "fb-${{ github.event.number || github.run_id }}"
          no_traffic: true
          skip_default_labels: true

Log output

Logs are attached to the issue as a text file while the log is too long

Additional information

I'm trying to implement feature branch deployments where the main infra setup is managed by Pulumi/terraform and feature branches are deployed with GH action.

sethvargo commented 4 months ago

Hi there - could you please provide the debug output for the complete GitHub Actions workflow run? Sorry, I missed the link.

The gcloud command that is running is:

gcloud run deploy <SERVICE_NAME> --image europe-west2-docker.pkg.dev/***/docker-registry/<CONTAINER_NAME>:fb-39 --tag fb-39 --no-traffic --timeout 6s --format json --region europe-west2 --project ***

Given that, I think this could be a gcloud bug then? Are you able to reproduce this issue using just the gcloud CLI?

xSAVIKx commented 4 months ago

Hey @sethvargo, yeah it looks like it's on the gcloud, not the action itself while the action is only prepping the CLI command.

I don't have a way to reproduce this with just the CLI right now, but will try to some time soon hopefully.

sethvargo commented 4 months ago

Okay thanks - if you can reproduce it via the gcloud CLI, you can file a bug at: https://cloud.google.com/sdk/docs/getting-support

nwaughachukwuma commented 4 months ago

You can temporarily set gcloud_version input option to the last working version.

See the options here

sethvargo commented 3 months ago

Hi there - I'm going to close this out since it's been about a month without a response. If this is still happening, please provide output that shows this working with the gcloud command but failing in the GitHub Action. Thanks!