-
-
Notifications
You must be signed in to change notification settings - Fork 138
90 lines (76 loc) · 2.95 KB
/
Copy pathbuild-deploy.yaml
File metadata and controls
90 lines (76 loc) · 2.95 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
name: Build & Deploy
on:
workflow_call:
inputs:
sha-tag:
description: "A short-form SHA tag for the commit that triggered this workflow"
required: true
type: string
jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
persist-credentials: false
# The current version (v3) of Docker's build-push action uses
# buildx, which comes with BuildKit features that help us speed
# up our builds using additional cache features. Buildx also
# has a lot of other features that are not as relevant to us.
#
# See https://github.com/docker/build-push-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
- name: Login to Github Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build the container, including an inline cache manifest to
# allow us to use the registry as a cache source.
- name: Build and push
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
file: ./Dockerfile
push: true
cache-from: type=registry,ref=ghcr.io/python-discord/site:latest
cache-to: type=inline
tags: |
ghcr.io/python-discord/site:latest
ghcr.io/python-discord/site:${{ inputs.sha-tag }}
build-args: |
git_sha=${{ github.sha }}
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
repository: python-discord/infra
path: infra
persist-credentials: false
- uses: azure/setup-kubectl@829323503d1be3d00ca8346e5391ca0b07a9ab0d # v5.1.0
- name: Authenticate with Kubernetes
uses: azure/k8s-set-context@8698eba2499e9012f0d5085f8798077cce4bc526 # v5
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG }}
- name: Deploy to Kubernetes
uses: Azure/k8s-deploy@51ca02a8b7225fbd0924aac359c5b336a5f1e5b4 # v7.0.0
with:
namespace: web
manifests: |
infra/kubernetes/namespaces/web/site/deployment.yaml
images: 'ghcr.io/python-discord/site:${{ inputs.sha-tag }}'
- name: Purge Cloudflare Edge Cache
uses: jakejarvis/cloudflare-purge-action@eee6dba0236093358f25bb1581bd615dc8b3d8e3 # master
env:
CLOUDFLARE_ZONE: 989c984a358bfcd1e9b9d188cc86c1df
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }}