Skip to content

TEST GithubActions 2 #4

TEST GithubActions 2

TEST GithubActions 2 #4

name: Deploy to Cloud Run from Source
on:
push:
branches: ['main']
env:
PROJECT_ID: regrets-reporter-dev # TODO: update Google Cloud project id
SERVICE: tiktok-reporter-app-be # TODO: update Cloud Run service name
REGION: europe-west1 # TODO: update Cloud Run service region
jobs:
deploy:
# Add 'id-token' with the intended permissions for workload identity federation
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v2
- id: auth
name: Google Auth
uses: 'google-github-actions/auth@v0'
with:
token_format: access_token
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}' # e.g. - projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}' # e.g. - my-service-account@my-project.iam.gserviceaccount.com
access_token_lifetime: 300s
- id: loginar
name: Login to Artifact Registry
uses: docker/login-action@v1
with:
registry: <gar-region>-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- id: get-tag
name: Get tag
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}
- id: docker-push-tagged
name: Tag Docker image and push to Google Artifact Registry
uses: docker/build-push-action@v2
with:
push: true
tags: |
europe-west1-docker.pkg.dev/regrets-reporter-dev/tiktok-reporter-app-be/regrets-reporter:${{ steps.get-tag.outputs.short_ref }}
europe-west1-docker.pkg.dev/regrets-reporter-dev/tiktok-reporter-app-be/regrets-reporter:latest
- id: populate-configs
uses: 73h/gae-app-yaml-replace-env-variables@v0.3
env:
PG_HOST: ${{ secrets.PG_HOST }}
PG_PORT: ${{ secrets.PG_PORT }}
PG_Type: ${{ secrets.PG_Type }}
PG_DATABASE: ${{ secrets.PG_DATABASE }}
PG_USERNAME: ${{ secrets.PG_USERNAME }}
PG_PASSWORD: ${{ secrets.PG_PASSWORD }}
PG_ROOT_PASSWORD: ${{ secrets.PG_ROOT_PASSWORD }}
PG_SYNCHRONIZE: ${{ secrets.PG_SYNCHRONIZE }}
PG_LOGGING: ${{ secrets.PG_LOGGING }}
with:
app_yaml_path: '.github/configs/app.yaml'
- id: deploy
name: Deploy Docker image to App Engine
uses: google-github-actions/deploy-appengine@v1
with:
deliverables: '.github/configs/app.yaml'
# - name: Deploy to Cloud Run
# id: deploy
# uses: google-github-actions/deploy-cloudrun@v0
# with:
# service: ${{ env.SERVICE }}
# region: ${{ env.REGION }}
# # NOTE: If required, update to the appropriate source folder
# source: ./
# If required, use the Cloud Run url output in later steps
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}