Merge pull request #245 from ThatConference/bouncer/chore/node-20 #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: bouncer Push Master | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- "functions/bouncer/**" | |
jobs: | |
build: | |
name: Build bouncer | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: npm ci, run validate | |
run: | | |
cd functions/bouncer | |
pwd | |
cp .env.sample .env | |
npm ci | |
npm run validate | |
- name: Post-Build Copies | |
run: | | |
cd functions/bouncer | |
pwd | |
npm pkg delete scripts.build | |
cp ./package.json __build__/ | |
cp ./package-lock.json __build__/ | |
git rev-list --count master > __build__/ccnt.txt | |
- name: Archive Build Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: tc-api | |
path: functions/bouncer/__build__ | |
- name: Slack Notification | |
uses: 8398a7/action-slack@v3 | |
with: | |
fields: repo,message,commit,author,eventName,ref,workflow,job,took | |
status: ${{ job.status }} | |
author_name: Push Master CI | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_DEV_NOTIFICATIONS }} | |
if: job.status == 'failure' || job.status == 'cancelled' | |
deploy-image: | |
name: Deploy Bouncer | |
needs: build | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Download Build Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: tc-api | |
path: tc-api | |
- name: Setup google auth for github actions | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCLOUD_AUTH }} | |
- name: Setup gcloud Actions | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
version: "437.0.1" | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
- name: write .env file | |
run: | | |
gcloud secrets versions access latest --secret prod-bouncer-env > tc-api/.env | |
C_CNT=$(cat tc-api/ccnt.txt) | |
rm -f tc-api/ccnt.txt | |
SENTRYREL=SENTRY_VERSION=bouncer@$(cat tc-api/package.json | jq '.version' | tr -d '"')-$C_CNT.$(echo $GITHUB_SHA | cut -c1-7) | |
echo "" >> tc-api/.env | |
echo $SENTRYREL >> tc-api/.env | |
echo "SENTRYREL=$SENTRYREL" >> $GITHUB_ENV | |
env: | |
CLOUDSDK_CORE_PROJECT: ${{ secrets.GCP_PROJECT_ID }} | |
- name: Checks and verifications | |
run: | | |
echo "**********" | |
echo $SENTRYREL | |
echo $GITHUB_SHA | |
echo $GITHUB_REF | |
echo "**********" | |
echo $PWD | |
ls -lasiR | |
- name: Run GCP Deploy Function - bouncer | |
run: gcloud functions deploy bouncer --runtime nodejs20 --trigger-http --source $PWD/tc-api --allow-unauthenticated --entry-point handler --memory 256MB | |
env: | |
CLOUDSDK_CORE_PROJECT: ${{ secrets.GCP_PROJECT_ID }} | |
- name: Slack Notification | |
uses: 8398a7/action-slack@v3 | |
with: | |
fields: repo,message,commit,author,eventName,ref,workflow,job,took | |
status: ${{ job.status }} | |
author_name: Push Master CI | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_DEV_NOTIFICATIONS }} | |
if: always() |