GithubHelp home page GithubHelp logo

google-github-actions / create-cloud-deploy-release Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 10.0 1.62 MB

A GitHub Action for creating releases via Cloud Deploy.

Home Page: https://cloud.google.com/deploy

License: Apache License 2.0

JavaScript 4.41% TypeScript 95.59%
actions ci-cd cloud-deploy gcp github-actions google-cloud google-cloud-deploy google-cloud-platform

create-cloud-deploy-release's People

Contributors

aelawson avatar coconutruben avatar dependabot[bot] avatar google-github-actions-bot avatar henrybell avatar lukebarge avatar sethvargo avatar verbanicm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

create-cloud-deploy-release's Issues

--deploy_parameters option is present when no deploy parameters are set

TL;DR

--deploy_parameters option is present when no deploy parameters are set. The gcloud fails because there is no argument provided to it

Expected behavior

When no deploy parameters are provided, there should be no --deploy_parameters in the output command

Observed behavior

When no deploy parameters are provided, --deploy_parameters is present in the output command but without an argument passed to it. This causes the gcloud to fail.

The cause is https://github.com/google-github-actions/actions-utils/blob/9c1562ded0e506d4d957f6e3a56fb1dbfa6cb59b/src/kv.ts#L89 which returns an empty object if there are no arguments provided which evaluates truthy here

const deployParameters = parseKVString(getInput('deploy_parameters'));

Action YAML

name: Build app and create a release in Cloud Deploy

on:
  push:
    branches:
      - $default_branch

env:
  PROJECT_ID: nifty-might-418012 
  GAR_LOCATION: europe-west2 
  REGION: europe-west2 
  APP: app

jobs:
  deploy:
    permissions:
      contents: 'read'
      id-token: 'write'

    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout'
        uses: 'actions/checkout@v3'

      - name: 'Google auth'
        id: 'auth'
        uses: 'google-github-actions/auth@v2'
        with:
          credentials_json: '${{ secrets.GCP_SA_KEY }}' # Replace with the name of your GitHub Actions secret


      - name: 'Set up Cloud SDK'
        uses: 'google-github-actions/setup-gcloud@v1'
        with:
          project_id: '${{ env.PROJECT_ID }}'

      - name: 'Docker auth'
        run: |-
          gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev

      - name: 'Build and push container'
        run: |-
          docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.APP }}/${{ env.APP }}:${{ github.sha }}" .
          docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.APP }}/${{ env.APP }}:${{ github.sha }}"

      - name: 'Render templatised config manifests'
        run: |-
          export PROJECT_ID="${{ env.PROJECT_ID }}"
          export REGION="${{ env.REGION }}"
          for template in $(ls config/*.template.yaml); do envsubst < ${template} > ${template%%.*}.yaml ; done

      - name: 'Create Cloud Deploy delivery pipeline'
        run: |-
          gcloud deploy apply --file config/clouddeploy.yaml --region ${{ env.GAR_LOCATION }}

      - name: 'Create release name'
        run: |-
          echo "RELEASE_NAME=${{ env.APP }}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV}

      - name: 'Create Cloud Deploy release'
        id: 'release'
        uses: 'google-github-actions/create-cloud-deploy-release@v0'
        with:
          delivery_pipeline: '${{ env.APP }}'
          name: '${{ env.RELEASE_NAME }}'
          region: '${{ env.REGION }}'
          description: '${{ env.GITHUB_COMMIT_MSG }}'
          skaffold_file: 'config/skaffold.yaml'
          images: 'app=${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.APP }}/${{ env.APP }}:${{ github.sha }}'

      - name: 'Report Cloud Deploy release'
        run: |-
          echo "Created release ${{ steps.release.outputs.name }} "
          echo "Release link ${{ steps.release.outputs.link }} "

Log output

Error: create-cloud-deploy-release failed with: failed to execute gcloud command `gcloud deploy releases create medi-quiz-92cb7cd-18 --delivery-pipeline medi-quiz --region europe-west2 --images app=europe-west2-docker.pkg.dev/nifty-might-418012/medi-quiz/medi-quiz:92cb7cd0342c1a956538d1b799eb8bc1009be6a2 --skaffold-file config/skaffold.yaml --deploy-parameters  --annotations commit=https://github.com/lukebarge/medi-quiz/commit/92cb7cd0342c1a956538d1b799eb8bc1009be6a2,git-sha=92cb7cd0342c1a956538d1b799eb8bc1009be6a2 --labels managed-by=github-actions --format json`: Creating temporary tarball archive of 45 file(s) totalling 539.6 KiB before compression.

Additional information

No response

Flags input results in unrecognized argument error

TL;DR

When creating a new Cloud Deploy release with this GH action and setting some flags input, the action fails and results in an unrecognized argument error instead of using the specified flag.

Expected behavior

A successful Cloud Deploy release was created using the skaffold_preview version that was specified through the --skaffold-version flag.

Observed behavior

The GH action fails to create a Cloud Deploy release because it results in an unrecognized argument error.

Action YAML

name: Create a release in Cloud Deploy
on:
  push:
    branches:
      - main
env:
  PIPELINE: deploy-test
  REGION: us-east4

jobs:
  deploy-test:
    permissions:
      contents: 'read'
      id-token: 'write'

    runs-on: ubuntu-latest
    steps:
    - name: Checkout repo
      uses: actions/[email protected]

    - name: 'Google auth'
      id: 'auth'
      uses: 'google-github-actions/auth@v1'
      with:
        workload_identity_provider: '${{ secrets.WIF_PROVIDER }}'
        service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}'

    - name: 'Create release name'
      run: |-
        echo "RELEASE_NAME=release-${GITHUB_SHA::7}" >> ${GITHUB_ENV}

    - name: 'Create Cloud Deploy release'
      id: 'release'
      uses: 'google-github-actions/[email protected]'
      with:
        delivery_pipeline: ${{ env.PIPELINE }}
        name: ${{ env.RELEASE_NAME }}
        region: ${{ env.REGION }}
        description: Test-Deployment
        skaffold_file: 'config/skaffold.yaml'
        flags: '--skaffold-version=skaffold_preview'

    - name: 'Report Cloud Deploy release'
      run: |-
        echo "Created release ${{ steps.release.outputs.name }} "
        echo "Release link ${{ steps.release.outputs.link }} "

Log output

Run google-github-actions/[email protected]

/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/10d2e040 -f /home/runner/work/_temp/0dbbe185
Successfully authenticated

Running: gcloud deploy releases create Release-18ff0ee --delivery-pipeline deploy-test --region us-east4 --skaffold-file config/skaffold.yaml --annotations commit=https://github.com/org/repo/commit/18ff0ee18ff0ee18ff0ee18ff0ee18ff0ee18ff0ee,git-sha= ecdeca633a230bfade4cc8195ae23af030922319 --labels managed-by=github-actions --flags --skaffold-version skaffold_preview --format json

Error: create-cloud-deploy-release failed with: failed to execute gcloud command `gcloud deploy releases create Release-18ff0ee --delivery-pipeline deploy-test --region us-east4 --skaffold-file config/skaffold.yaml --annotations commit=https://github.com/org/repo/commit/18ff0ee18ff0ee18ff0ee18ff0ee18ff0ee18ff0ee,git-sha= ecdeca633a230bfade4cc8195ae23af030922319 --labels managed-by=github-actions --flags --skaffold-version skaffold_preview --format json`: ERROR: (gcloud.deploy.releases.create) unrecognized arguments:
  --flags (did you mean '--flags-file'?)

  To search the help text of gcloud commands, run:
  gcloud help -- SEARCH_TERMS

Additional information

This might be happening here: https://github.com/google-github-actions/create-cloud-deploy-release/blob/main/src/main.ts#L156-L157
where the --flags string is getting pushed into the gcloud command before appending the actual flags that have been passed in. It also seems like the flags might be getting parsed weirdly, since the input was originally --skaffold-version=skaffold_preview but the final command that was executed contains --skaffold-version skaffold_preview, which changed the = to a space.

Skaffold file always required

TL;DR

Per the documentation, it seemed that I can omit a skaffold.yml if providing images, however am seeing the following (and have confirmed the value for images is being properly passed to the CLI call):

ERROR: (gcloud.deploy.releases.create) Could not find skaffold file. File [./skaffold.yaml] does not exist

Expected behavior

gcloud deploy releases create --help insinuates images should be enough?

Observed behavior

No response

Action YAML

with:
  delivery_pipeline: ...
  name: ...
  region: ...
  description: ...
  images: ...

Log output

No response

Additional information

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.