Skip to content

CD Apps

CD Apps #32

Workflow file for this run

name: CD Apps
on:
release:
types: [published]
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GCP_CD }}
PROJECT: "artist-2d"
DEPLOY_ENV: "dev"
REGION: "us-west1"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_CD }}'
- name: Set Up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: '>= 363.0.0'
- name: Docker auth for GCP Artifact Registry
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
- name: Set Release Envvars
# Split "APP:VERSION" into two envvars.
run: |
echo $GITHUB_REF_NAME
echo "APP=$(echo $GITHUB_REF_NAME | cut -d '-' -f 1)" >> $GITHUB_ENV
echo "VERSION=$(echo $GITHUB_REF_NAME | cut -d '-' -f 2)" >> $GITHUB_ENV
- name: Get Image name
run: |
echo "IMAGE=${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT }}/${{ env.PROJECT }}/${{ env.APP }}:${{ env.VERSION }}" >> $GITHUB_ENV
- name: Build Release Image
run: |
echo "Building image ${{ env.IMAGE }}"
docker build ${{ env.APP }}/ -t ${{ env.IMAGE }}
docker push ${{ env.IMAGE }}
- name: Release It!
run: |
cd ${{ env.APP }}
export REVISION_NAME=$( echo "${{ env.APP}}-${{ env.VERSION }}" | sed s/\\./-/g )
echo "Depoying Service file..."
envsubst < service.yaml
# Yaml doesn't support variable sub, so use envsubst and read file from stdin.
envsubst < service.yaml | \
gcloud run services replace - --region ${{ env.REGION }}