-
Notifications
You must be signed in to change notification settings - Fork 3
71 lines (59 loc) · 2.92 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
71
name: Build app and update Docker image
on:
# Use the release event because push events are not triggered for commits tagged with more than three tags:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push.
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
if: startsWith(github.ref_name, '@netwerk-digitaal-erfgoed/network-of-terms-graphql') || startsWith(github.ref_name, '@netwerk-digitaal-erfgoed/network-of-terms-reconciliation')
steps:
- uses: actions/checkout@v3
# https://github.com/dhoulb/multi-semantic-release#git-tags tags packages `@scope/package-name@version`.
- uses: actions-ecosystem/[email protected]
id: parse-tag
with:
text: ${{ github.ref_name }}
regex: '^@netwerk-digitaal-erfgoed/(.+)@(.+)$'
# See https://github.com/docker/build-push-action#complete-workflow.
- name: Set variables
id: vars
run: |
VERSION_TAG=${GITHUB_REF#refs/tags/}
echo "package_name=${{steps.parse-tag.outputs.group1}}" >> $GITHUB_OUTPUT
echo "version_tag=${{steps.parse-tag.outputs.group2}}" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "docker_image=ghcr.io/netwerk-digitaal-erfgoed/${{steps.parse-tag.outputs.group1}}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# See https://github.com/docker/build-push-action/issues/126.
driver-opts: image=moby/buildkit:master
- name: Log in to Docker registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
- name: Build and push image to registry
uses: docker/[email protected]
with:
context: .
push: true
build-args: PACKAGE_DIR=packages/${{ steps.vars.outputs.package_name }}
tags: |
${{ steps.vars.outputs.docker_image }}:${{ steps.vars.outputs.sha_short }}
${{ steps.vars.outputs.docker_image }}:${{ steps.vars.outputs.version_tag }}
${{ steps.vars.outputs.docker_image }}:latest
- uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Store DigitalOcean credentials
run: doctl kubernetes cluster kubeconfig save nde
# See https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment
- name: Update deployment
run: |
kubectl set image deployment/${{ steps.vars.outputs.package_name }} app=${{ steps.vars.outputs.docker_image }}:${{ steps.vars.outputs.sha_short }}
- name: Verify deployment
run: kubectl rollout status deployment/${{ steps.vars.outputs.package_name }} --timeout=120s