Skip to content

Merge pull request #472 from georgetown-cset/twitter-card-image-full-… #141

Merge pull request #472 from georgetown-cset/twitter-card-image-full-…

Merge pull request #472 from georgetown-cset/twitter-card-image-full-… #141

Workflow file for this run

name: Deployment
on:
push:
branches:
- master
- version2
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v3
- name: Get current date
id: date
run: echo "today=$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_OUTPUT
- name: 'Authenticate to Google Cloud - building'
id: 'auth_build'
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/855475113448/locations/global/workloadIdentityPools/eto-github/providers/eto-github'
service_account: 'eto-artifact-registry-github@gcp-cset-projects.iam.gserviceaccount.com'
token_format: 'access_token'
- name: 'Log into Artifact Registry'
uses: 'docker/login-action@v2'
with:
registry: us-east1-docker.pkg.dev
username: 'oauth2accesstoken'
password: '${{ steps.auth_build.outputs.access_token }}'
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: 'Cache node_modules'
uses: actions/cache@v3
with:
path: web/gui-v2/node_modules
key: js-${{ hashFiles('web/gui-v2/package-lock.json') }}
- name: 'Get node_modules'
working-directory: web/gui-v2
run: |
npm run artifactregistry-login
npm install
- name: 'Build assets'
env:
NODE_OPTIONS: "--max_old_space_size=8192"
working-directory: web/gui-v2
run: |
npm install -g gatsby-cli
gatsby build
- name: 'Authenticate to Google Cloud - deployment'
id: 'auth_deploy'
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/855475113448/locations/global/workloadIdentityPools/eto-github/providers/eto-github'
service_account: 'eto-cd-github@gcp-cset-projects.iam.gserviceaccount.com'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: 'Copy built assets to cloud'
id: 'gcloud'
working-directory: web/gui-v2
run: |
gsutil -m cp -r public gs://eto-cd/parat/${{ steps.date.outputs.today }}
- name: 'Copy built assets to compute engine'
id: 'compute-ssh'
uses: 'google-github-actions/ssh-compute@v0'
with:
instance_name: 'parat-v2-dev'
zone: 'us-east1-c'
project_id: 'gcp-cset-projects'
user: 'eto-cd-github'
ssh_private_key: '${{ secrets.GCP_SSH_PRIVATE_KEY }}'
command: |
gsutil -m cp -r gs://eto-cd/parat/${{ steps.date.outputs.today }} .
sudo rm -r /var/www/html/*
sudo mv ${{ steps.date.outputs.today }}/* /var/www/html/
rm -rf ${{ steps.date.outputs.today }}
gsutil -m rm -r gs://eto-cd/parat/${{ steps.date.outputs.today }}