-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (113 loc) · 3.61 KB
/
deploy.yaml
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Deploy
on:
workflow_run:
workflows: [CI]
branches: [main]
types:
- completed
env:
IMAGE_NAME: obr-web
GH_REGISTRY: ghcr.io
GH_ORGANIZATION: digris
GCP_PROJECT_ID: open-broadcast
GCP_SERVICE: obr-web
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout
uses: actions/checkout@v3
# prepare github
- name: Authorize github container registry
uses: docker/login-action@v1
with:
registry: ${{ env.GH_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# prepare GCP
- name: GCP auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ env.GCP_PROJECT_ID }}
- name: Authorize GCP container registry
run: gcloud auth configure-docker
# build & push image
- name: Set up docker buildx
uses: docker/setup-buildx-action@v1
- name: Set outputs
id: vars
#run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for image
id: meta
uses: docker/metadata-action@v2
with:
images: |
${{ env.GH_REGISTRY }}/${{ env.GH_ORGANIZATION }}/${{ env.IMAGE_NAME }}
gcr.io/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_SERVICE }}
tags: |
type=ref,event=branch
type=sha
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
# https://github.com/docker/buildx/issues/1533
provenance: false
context: .
file: docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_SHORT_SHA=${{ steps.vars.outputs.sha_short }}
- name: Deploy to GCP cloud run
run: gcloud builds submit --config gcp/migrate-deploy.yaml --timeout=1200 --async
- name: Inform slack channel
id: slack
uses: slackapi/[email protected]
with:
payload: |
{
"text": "openbroadcast.ch - deploying ${{ steps.vars.outputs.sha_short }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
sentry-release:
needs: [deploy]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: '20'
- name: Set variables
id: vars
run: echo "version=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- run: echo ${{ steps.vars.outputs.version }}
- run: |
npm install -g yarn
yarn install
yarn 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
version: ${{ steps.vars.outputs.version }}
sourcemaps: './build'