Skip to content

Continuous Delivery (GCR) #480

Continuous Delivery (GCR)

Continuous Delivery (GCR) #480

Workflow file for this run

name: Continuous Delivery (GCR)
on:
workflow_dispatch:
push:
branches:
- master
- master-*
- develop
- develop-*
- build/*
jobs:
build:
timeout-minutes: 20
runs-on: ubuntu-latest
strategy:
matrix:
env:
- MANDANT: imp
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Install
uses: bahmutov/npm-install@v1
- name: Get repository-name, branch-name and version-name
run: |
echo "APP=$(echo ${GITHUB_REPOSITORY##*/})" >> $GITHUB_ENV
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
echo "VERSION_NAME=$(echo $(echo ${GITHUB_REF#refs/heads/} | cut -c -52)-$(git rev-parse --short ${GITHUB_SHA}) | sed -e 's/[^a-zA-Z0-9]/-/g')" >> $GITHUB_ENV
- name: Get environment by branch
run: |
echo "ENV=$(if [[ ${{ env.BRANCH_NAME }} =~ ^master ]]; then echo "production"; else echo "test"; fi)" >> $GITHUB_ENV
- name: Checkout and sync "icmaa/shop-workspace" repo
run: |
yarn global add @icmaa/config-sync
export CONFIG_BRANCH=$(if [[ ${{ env.BRANCH_NAME }} =~ ^master ]]; then echo "-b master"; fi)
config-sync -t ${{ secrets.PAT }} -r vue-storefront $CONFIG_BRANCH -d ./
- name: Build "${{ env.APP }}"
run: yarn build
env:
NODE_CONFIG_ENV: ${{ env.ENV }}
NODE_APP_INSTANCE: ${{ matrix.env.MANDANT }}
- name: Register GCP credentials
uses: 'google-github-actions/auth@v0'
id: auth
with:
credentials_json: ${{ env.ENV == 'production' && secrets.GCP_VSF_SA_KEY_PROD || secrets.GCP_VSF_SA_KEY_TEST }}
- name: Set up GCP Cloud SDK
uses: google-github-actions/setup-gcloud@v0
- name: Upload files to Google Cloud CDN
id: upload-folder
uses: google-github-actions/upload-cloud-storage@v0
with:
path: dist
destination: icmaa-${{ matrix.env.MANDANT }}-${{ env.ENV == 'production' && 'prod' || 'test' }}-vsf-assets
- name: Build and deploy in GCP
run: |
gcloud builds submit --quiet --config cloudbuild-${{ matrix.env.MANDANT }}-${{ env.ENV == 'production' && 'prod' || 'test' }}.yaml
gcloud run deploy ${{ env.APP }} --region europe-west3 --image europe-docker.pkg.dev/icmaa-shop-imp-${{ env.ENV == 'production' && 'prod' || 'test' }}-01/eu.gcr.io/${{ env.APP }}:latest