Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GCloud actions to the latest versions #957

Merged
merged 2 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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