-
-
Notifications
You must be signed in to change notification settings - Fork 13
176 lines (158 loc) · 6.36 KB
/
deploy.yaml
File metadata and controls
176 lines (158 loc) · 6.36 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Deploy
on:
workflow_run:
workflows: ["CI"]
branches:
- main
types:
- completed
workflow_dispatch:
inputs:
deploy_environment:
description: 'Environment to deploy to'
required: false
default: 'develop'
type: choice
options:
- production
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.inputs.deploy_environment || 'production' }}
cancel-in-progress: true
permissions:
{}
jobs:
# copied from the ci step
build:
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_environment == 'develop'
name: Build & Push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # used to publish to GHCR
steps:
# Create a commit SHA-based tag for the container repositories
- name: Create SHA Container Tag
id: sha_tag
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "tag=$tag" >> $GITHUB_OUTPUT
# Check out the current repository in the `monty` subdirectory
- name: Checkout code
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
path: monty
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to Github Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push the container to the GitHub Container
# Repository. The container will be tagged as "latest"
# and with the short SHA of the commit.
- name: Build and push
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: monty/
file: monty/Dockerfile
push: true
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/monty-python-beta:latest
cache-to: type=inline
tags: |
ghcr.io/${{ github.repository_owner }}/monty-python-beta:latest
ghcr.io/${{ github.repository_owner }}/monty-python-beta:${{ steps.sha_tag.outputs.tag }}
build-args: |
git_sha=${{ github.sha }}
deploy:
environment: ${{ github.event.inputs.deploy_environment || 'production' }}
needs: build
if: always() && github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch'
name: Deploy to k8s
runs-on: ubuntu-latest
permissions:
contents: read # used to checkout the repo
packages: read # used to pull the container
steps:
- name: Create SHA Container Tag
id: sha_tag
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
repository: onerandomusername/kubernetes
token: ${{ secrets.REPO_TOKEN }}
persist-credentials: false
- name: Install kubectl
uses: azure/setup-kubectl@776406bce94f63e41d621b960d78ee25c8b76ede # v4.0.1
with:
version: 'latest'
- name: Authenticate with Kubernetes
uses: azure/k8s-set-context@ae59a723ba9abe7a9655538854a025448dbab4aa # v4.0.2
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG }}
- name: Login to Github Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy beta to Kubernetes
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_environment == 'develop'
uses: azure/k8s-deploy@6f7c489cecd8da05646259d9fa3daae92e095c7b # v5.0.4
with:
manifests: |
monty/beta/deployment.yaml
images: 'ghcr.io/onerandomusername/monty-python-beta:${{ steps.sha_tag.outputs.tag }}'
# annotate-namespace: false
# strategy: 'none'
- name: Deploy Stable to Kubernetes
if: github.event_name != 'workflow_dispatch' || github.event.inputs.deploy_environment != 'develop'
uses: azure/k8s-deploy@6f7c489cecd8da05646259d9fa3daae92e095c7b # v5.0.4
with:
manifests: |
monty/deployment.yaml
images: 'ghcr.io/onerandomusername/monty-python:${{ steps.sha_tag.outputs.tag }}'
# annotate-namespace: false
# strategy: 'none'
create_sentry_release:
name: Create Sentry Release
needs: build
if: always()
environment: ${{ github.event.inputs.deploy_environment || 'production' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Create a Sentry.io release
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_environment == 'develop'
uses: tclindner/sentry-releases-action@6aa8f28371f3b57460bbaefce469471b117b5620 # v1.3.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: monty-python-beta
with:
tagName: ${{ github.sha }}
# because for whatever reason we currently have two seperate sentry projects, not one.
# TODO(onerandomusername): consolidate
environment: production
releaseNamePrefix: monty@
- name: Create a Sentry.io release
if: github.event_name != 'workflow_dispatch' || github.event.inputs.deploy_environment != 'develop'
uses: tclindner/sentry-releases-action@6aa8f28371f3b57460bbaefce469471b117b5620 # v1.3.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: monty-python
with:
tagName: ${{ github.sha }}
environment: production
releaseNamePrefix: monty@