Skip to content

Try adding the npmrc again #43

Try adding the npmrc again

Try adding the npmrc again #43

name: Build and Maybe Deploy
on:
push:
branches:
- '*'
# Note this is NOT REGEX - see https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
tags:
- '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].[0-9]+'
jobs:
build-deploy-dev:
runs-on: ubuntu-latest
env:
CI: 'true'
FORCE_COLOR: 'true'
GOOGLE_AUTH_JSON_DEV: ${{ secrets.GCP_DEPLOY_SERVICE_ACCOUNT_MABL_DEV }}
GOOGLE_AUTH_JSON_PROD: ${{ secrets.GCP_DEPLOY_SERVICE_ACCOUNT_MABL_PROD }}
GOOGLE_AUTH_JSON_DEPLOY: ${{ secrets.GCP_DEPLOY_SERVICE_ACCOUNT_MABL_DEPLOY }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
# Use caching to speed reload
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('package.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}
- name: Install Dependencies
run: |
echo "${{ secrets.NPMRC_READONLY_CONFIG }}" > .npmrc
npm ci
# Log versions to help debug builds
- name: Show Versions
run: |
echo "npm $(npm --version)"
echo "node: $(node --version)"
echo "gcloud: $(gcloud --version)"
- name: Build
run: |
npm run build
npm prune --production
- name: Auth to Dev
if: github.ref == 'refs/heads/main'
uses: google-github-actions/setup-gcloud@v0
with:
project_id: 'mabl-dev'
service_account_key: ${{ secrets.GCP_DEPLOY_SERVICE_ACCOUNT_MABL_DEV }}
- name: Deploy to Dev
if: github.ref == 'refs/heads/main'
run: |
GIT_SHA=${{ github.sha }}
GIT_SHA_SHORT=${GIT_SHA:0:7}
gcloud functions deploy ${{ secrets.WEBHOOK_NAME }}\
--runtime nodejs18\
--trigger-http\
--update-labels "app_hash=${GIT_SHA_SHORT},app_name=handle_plan_webhook"\
--project=mabl-dev\
--entry-point=handlePlanWebhook\
--region us-central1\
--allow-unauthenticated\
--set-env-vars=GCP_PROJECT=mabl-dev\
--service-account=${{ secrets.GCF_SERVICE_ACCOUNT_MABL_DEV }}\
--security-level=secure-always
- name: Auth to Prod
if: contains(github.ref, 'refs/tags/')
uses: google-github-actions/setup-gcloud@v0
with:
project_id: 'mabl-prod'
service_account_key: ${{ secrets.GCP_DEPLOY_SERVICE_ACCOUNT_MABL_PROD }}
- name: Deploy to Prod
if: contains(github.ref, 'refs/tags/')
run: |
GIT_SHA=${{ github.sha }}
GIT_SHA_SHORT=${GIT_SHA:0:7}
gcloud functions deploy ${{ secrets.WEBHOOK_NAME }}\
--runtime nodejs18\
--trigger-http\
--update-labels "app_hash=${GIT_SHA_SHORT},app_name=handle_plan_webhook"\
--project=mabl-prod\
--entry-point=handlePlanWebhook\
--region us-central1\
--allow-unauthenticated\
--set-env-vars=GCP_PROJECT=mabl-prod\
--service-account=${{ secrets.GCF_SERVICE_ACCOUNT_MABL_PROD }}\
--security-level=secure-always