-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (94 loc) · 3.18 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
name: Deploy to App Engine
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
setup-app-engine:
name: Prepare for App Engine
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
poetry self add poetry-plugin-export
poetry export -f requirements.txt --output requirements.txt --only main
- uses: actions/upload-artifact@v4
with:
name: requirements
path: requirements.txt
deploy-production-app-engine:
name: Deploy App Engine (production)
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write" # for OpenID Connect JWT Token
needs: setup-app-engine
environment:
name: production
url: ${{ steps.deploy.outputs.version_url }}
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- id: "auth"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: ${{ secrets.OIDC_PROVIDER }}
service_account: ${{ secrets.GCP_SA }}
- name: Get requirements.txt
uses: actions/download-artifact@v4
with:
name: requirements
- id: "deploy"
uses: "google-github-actions/deploy-appengine@v2"
with:
flags: "--no-cache"
- name: "Clean temporary container images"
run: |-
gcloud container images list --repository=eu.gcr.io/noplp-stats/app-engine-tmp/app/default \
--format="value(name)" | xargs -I {} sh -c 'gcloud container images delete {} --quiet --force-delete-tags'
deploy-pr-app-engine:
name: Deploy App Engine (pull_request)
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write" # for OpenID Connect JWT Token
needs: setup-app-engine
environment:
name: pull_request
url: ${{ steps.deploy.outputs.version_url }}
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- id: "auth"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: ${{ secrets.OIDC_PROVIDER }}
service_account: ${{ secrets.GCP_SA }}
- name: Get requirements.txt
uses: actions/download-artifact@v4
with:
name: requirements
- id: "deploy"
uses: "google-github-actions/deploy-appengine@v2"
with:
flags: "--no-cache"
promote: false
- name: Show PR environment URL
run: 'echo "${{ steps.deploy.outputs.version_url }}"'
- name: "Clean temporary container images"
run: |-
gcloud container images list --repository=eu.gcr.io/noplp-stats/app-engine-tmp/app/default \
--format="value(name)" | xargs -I {} sh -c 'gcloud container images delete {} --quiet --force-delete-tags'