-
-
Notifications
You must be signed in to change notification settings - Fork 41
107 lines (95 loc) · 3.19 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
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
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
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
- 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@v4
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 }}
# 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 }}'
# 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 }}