-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (57 loc) · 2.08 KB
/
deploy.yml
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
name: deploy
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
REPO: cashtrack/website
INFRA_REPO: cash-track/infra
INFRA_REPO_REF: main
CLUSTER: k8s-cash-track
NAMESPACE: cash-track
KUBECTL_BIN: https://storage.googleapis.com/kubernetes-release/release/v1.24.4/bin/linux/amd64/kubectl
jobs:
deploy:
runs-on: [self-hosted, Linux, x64]
permissions:
contents: read
packages: write
steps:
- name: Checkout infra repository
uses: actions/checkout@v4
with:
repository: ${{ env.INFRA_REPO }}
ref: ${{ env.INFRA_REPO_REF }}
path: deploy
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Install kubectl
run: |
curl -LO ${{ env.KUBECTL_BIN }}
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- name: Configure kubectl
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ env.CLUSTER }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
if: github.event_name != 'pull_request'
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REPO }}
tags: |
type=semver,pattern={{version}}
- name: Update deployment
env:
IMAGE: ${{ env.REPO }}:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
run: sed -i 's|${{ env.REPO }}:latest|'${IMAGE}'|' $GITHUB_WORKSPACE/deploy/services/website/deployment.yml
- name: Update definition
run: kubectl apply -f $GITHUB_WORKSPACE/deploy/services/website/
- name: Verify deployment
run: kubectl -n ${{ env.NAMESPACE }} rollout status deployment/website
- name: Verify service ready
run: kubectl -n ${{ env.NAMESPACE }} wait pods -l app=website --for condition=Ready --timeout=60s