Skip to content

Commit

Permalink
Update GCloud GH actions to the latest versions (#957)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuthan committed Nov 24, 2022
1 parent ef0d21a commit f8efc63
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
18 changes: 18 additions & 0 deletions .github/actions/gcloud/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: GCloud
description: Authenticate to Google Cloud and install SDK

inputs:
credentials_json:
required: true
description: The Google Cloud JSON service account key to use for authentication

runs:
using: composite
steps:
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ inputs.credentials_json }}

- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v1
8 changes: 3 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Authenticate on GCP
uses: google-github-actions/setup-gcloud@v0
- name: Setup GCloud
uses: ./.github/actions/gcloud
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: Configure Docker
run: gcloud auth configure-docker --quiet
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/undeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,23 @@ jobs:

env:
IMAGE_NAME: eu.gcr.io/${{ secrets.GCP_PROJECT_ID }}/turnilo
REF_NAME: ${{ github.head_ref }}
TAG_NAME: ${{ github.head_ref }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Authenticate on GCP
uses: google-github-actions/setup-gcloud@v0
- name: Setup GCloud
uses: ./.github/actions/gcloud
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: Undeploy app
run: |
gcloud run services delete turnilo-${REF_NAME//[^a-z0-9]/-} \
gcloud run services delete turnilo-${TAG_NAME//[^a-z0-9]/-} \
--region europe-west1 \
--quiet
- name: Delete Docker image
run: |
gcloud container images delete $IMAGE_NAME:${REF_NAME//[^a-z0-9]/-} --quiet
gcloud container images delete $IMAGE_NAME:${TAG_NAME//[^a-z0-9]/-} --quiet

0 comments on commit f8efc63

Please sign in to comment.