-
Notifications
You must be signed in to change notification settings - Fork 45
58 lines (49 loc) · 1.86 KB
/
Copy pathdocker.yml
File metadata and controls
58 lines (49 loc) · 1.86 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
name: Build and push image
on:
push:
branches: [master]
tags: ["*"]
env:
IMAGE: macadmins/crypt-server
TAG: ${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Load into the local daemon rather than pushing, so the migration check
# below runs against the exact image that gets published.
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
load: true
push: false
tags: ${{ env.IMAGE }}:${{ env.TAG }}
cache-from: type=gha
cache-to: type=gha
# docker/run.sh applies migrations at container startup, so a migration
# that imports cleanly but fails to apply would only break on deploy.
# No DB_* env means settings fall back to sqlite, same as run.sh sees.
- name: Check migrations apply
run: |
docker run --rm \
-e FIELD_ENCRYPTION_KEY="$(python3 -c 'import base64, os; print(base64.urlsafe_b64encode(os.urandom(32)).decode())')" \
"$IMAGE:$TAG" \
sh -c 'cd $APP_DIR && python3 manage.py migrate --noinput'
- name: Push
run: docker push "$IMAGE:$TAG"
# crypt-server-saml builds FROM this image, so it has to run after the push.
# Needs a PAT: GITHUB_TOKEN cannot dispatch to another repo.
- name: Trigger crypt-server-saml build
env:
GH_TOKEN: ${{ secrets.SAML_DISPATCH_TOKEN }}
run: |
gh api repos/grahamgilbert/crypt-server-saml/dispatches \
-f event_type=build \
-f "client_payload[tag]=$TAG"