-
-
Notifications
You must be signed in to change notification settings - Fork 48
129 lines (116 loc) · 3.9 KB
/
deploy.yaml
File metadata and controls
129 lines (116 loc) · 3.9 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
on:
workflow_call:
inputs:
artifact:
required: true
type: string
version:
required: true
type: string
secrets:
KUBECONFIG:
required: true
jobs:
deploy:
name: Build, push, & deploy
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Download image artifact
uses: actions/download-artifact@v5
with:
name: ${{ inputs.artifact }}
# Load the image to make use of common layers during the final build.
- name: Load image from archive
run: docker load -i ${{ inputs.artifact }}.tar
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout code
uses: actions/checkout@v5
with:
# The version script relies on history. Fetch 100 commits to be safe.
fetch-depth: 100
# Build the final production image and push it to GHCR.
# Tag it with both the short commit SHA and 'latest'.
- name: Build final image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
cache-from: |
ghcr.io/python-discord/snekbox-base:latest
ghcr.io/python-discord/snekbox-venv:latest
ghcr.io/python-discord/snekbox:latest
cache-to: type=inline
tags: |
ghcr.io/python-discord/snekbox:latest
ghcr.io/python-discord/snekbox:${{ inputs.version }}
localhost:5000/local/snekbox:${{ inputs.version }}
- name: Build PyDis final image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.pydis
push: true
cache-from: |
ghcr.io/python-discord/snekbox:latest-pydis
build-args: SNEKBOX_IMAGE=localhost:5000/local/snekbox:${{ inputs.version }}
cache-to: type=inline
tags: |
ghcr.io/python-discord/snekbox:latest-pydis
ghcr.io/python-discord/snekbox:${{ inputs.version }}-pydis
# Deploy to Kubernetes.
- name: Install kubectl
uses: azure/setup-kubectl@v4
- name: Authenticate with Kubernetes
uses: azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG }}
- name: Deploy to Kubernetes
uses: azure/k8s-deploy@v5
with:
namespace: snekbox
manifests: deployment.yaml
images: 'ghcr.io/python-discord/snekbox:${{ inputs.version }}-pydis'
# Push the base image to GHCR, with an inline cache manifest.
- name: Push base image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
target: base
push: true
cache-from: ghcr.io/python-discord/snekbox-base:latest
cache-to: type=inline
tags: |
ghcr.io/python-discord/snekbox-base:latest
ghcr.io/python-discord/snekbox-base:${{ inputs.version }}
# Push the venv image to GHCR, with an inline cache manifest.
- name: Push venv image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
target: venv
push: true
cache-from: |
ghcr.io/python-discord/snekbox-base:latest
ghcr.io/python-discord/snekbox-venv:latest
cache-to: type=inline
tags: |
ghcr.io/python-discord/snekbox-venv:latest
ghcr.io/python-discord/snekbox-venv:${{ inputs.version }}