update to apollo 4 and sentry 8 and stuff #43
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: Build and Deploy to Cloud Run | |
on: | |
push: | |
branches: | |
- main | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT }} | |
SERVICE: tricktionary-api | |
REGION: us-central1 | |
jobs: | |
setup-build-publish-deploy: | |
name: Setup, Build, Publish, and Deploy | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# Setup gcloud CLI | |
- uses: google-github-actions/[email protected] | |
with: | |
service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
project_id: ${{ secrets.GCP_PROJECT }} | |
export_default_credentials: true | |
# Configure Docker to use the gcloud command-line tool as a credential | |
# helper for authentication | |
- name: Authorize Docker push | |
run: gcloud auth configure-docker | |
# Build the Docker image | |
- name: Build | |
run: |- | |
docker build \ | |
--tag "gcr.io/$PROJECT_ID/$SERVICE:$GITHUB_SHA" \ | |
--build-arg GITHUB_SHA="$GITHUB_SHA" \ | |
--build-arg GITHUB_REF="$GITHUB_REF" \ | |
. | |
# Push the Docker image to Google Container Registry | |
- name: Publish | |
run: |- | |
docker push "gcr.io/$PROJECT_ID/$SERVICE:$GITHUB_SHA" | |
- name: Deploy to Cloud Run | |
id: deploy | |
uses: google-github-actions/[email protected] | |
with: | |
service: ${{ env.SERVICE }} | |
image: gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
env_vars: SENTRY_DSN=${{ secrets.SENTRY_DSN }},GCP_PROJECT=${{ secrets.GCP_PROJECT }},APOLLO_KEY=${{ secrets.APOLLO_KEY }},APOLLO_GRAPH_ID=${{ secrets.APOLLO_GRAPH_ID }},APOLLO_GRAPH_VARIANT=current,APOLLO_SCHEMA_REPORTING=true,ALGOLIA_APP_ID=${{ secrets.ALGOLIA_APP_ID }},ALGOLIA_API_KEY=${{ secrets.ALGOLIA_API_KEY }} | |
secrets: STRIPE_SK=${{ secrets.STRIPE_SK_SECRET }} | |
flags: --max-instances=default --service-account=${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT }} | |
- name: Show Output | |
run: echo ${{ steps.deploy.outputs.url }} | |
sentry-release: | |
name: Create Sentry release | |
runs-on: ubuntu-latest | |
environment: production | |
needs: setup-build-publish-deploy | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Use Node.js 16 | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16 | |
- run: npm ci --prefer-offline | |
- run: npm run codegen | |
- run: npm run build | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: production | |
sourcemaps: ./dist | |
version_prefix: tricktionary-api@ |