This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
84 lines (74 loc) · 2.79 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Deploy
env:
PROJECT_ID: sentry-dev-tooling
on:
push:
branches:
- master
paths:
- "gitbot/*"
- Dockerfile
- "requirements.*.txt"
- .github/workflows/deploy.yml
workflow_dispatch:
inputs:
environment:
description: "Deploy to production or staging."
required: true
default: "staging"
jobs:
build-deploy:
name: build and deploy
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Metadata
id: info
run: |-
if [ ${{ github.event.inputs.environment }} == 'production' ]; then
echo "service=sentry-deploy-sync-hook" >> "$GITHUB_OUTPUT"
echo "environment=${{ github.event.inputs.environment }}" >> "$GITHUB_OUTPUT"
if [ ${{ github.ref }} != "refs/heads/master" ]; then
>&2 echo "We only allow deployments to production from the master branch."
exit 1
fi
else
echo "service=sentry-deploy-sync-hook-staging" >> "$GITHUB_OUTPUT"
echo "environment=staging" >> "$GITHUB_OUTPUT"
fi
RELEASE=$(./release_version.sh)
echo "release=${RELEASE}" >> "$GITHUB_OUTPUT"
- name: Setup Cloud SDK
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.PROJECT_ID }}
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
export_default_credentials: true # Set to true to authenticate the Cloud Run action
# This gives the ability to push to the Google Registry
- name: Authorize Docker push
run: gcloud auth configure-docker
- name: Build and Push Container
env:
RELEASE: ${{ steps.info.outputs.service }}
run: |-
docker build --build-arg RELEASE="${RELEASE}" -t us.gcr.io/$PROJECT_ID/sentry-deploy-sync-hook:$GITHUB_SHA .
docker push us.gcr.io/$PROJECT_ID/sentry-deploy-sync-hook:$GITHUB_SHA
- name: Deploy to Cloud Run
uses: google-github-actions/[email protected]
with:
service: ${{ steps.info.outputs.service }}
image: us.gcr.io/${{ env.PROJECT_ID }}/sentry-deploy-sync-hook:${{ github.sha }}
region: us-central1
- name: Sentry Release
uses: getsentry/[email protected]
# If we want to compare a release from a deployed PR we should report it, otherwise,
# it would only show up in the Sentry SaaS if an error occurred
with:
environment: ${{ steps.info.outputs.environment }}
version: ${{ steps.info.outputs.release }}
env:
SENTRY_ORG: sentry
SENTRY_PROJECT: gitbot
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}