-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (94 loc) · 2.84 KB
/
Copy pathmain.yml
File metadata and controls
101 lines (94 loc) · 2.84 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
91
92
93
94
95
96
97
98
99
100
101
---
name: CI
permissions:
contents: read
on:
push:
branches: main
pull_request:
workflow_dispatch:
# Note: we prefer to pin ubuntu versions explicitly rather than use
# ubuntu:latest, as that changes underneath us.
jobs:
check:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: "opensafely-core/setup-action@v1"
with:
install-uv: true
install-just: true
cache: uv
- name: Check formatting, linting and import sorting
run: just check
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: "opensafely-core/setup-action@v1"
with:
install-uv: true
install-just: true
cache: uv
- name: Set up test environment
run: just devenv
- name: Run tests
run: |
just test
test-docker:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: "opensafely-core/setup-action@v1"
with:
install-uv: true
install-just: true
cache: uv
- name: Build and test production image
run: |
just docker/build prod
- name: Smoke test production image
run: |
SKIP_BUILD=1 just docker/smoke-test
- name: Run docker tests
run: |
just docker/test
- name: Dump prod logs on failure
if: failure()
run: |
docker compose -f docker/docker-compose.yml logs prod
- name: Export production image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
docker save reference-gateway --output "${{ runner.temp }}/gateway-image.tar"
- name: Upload production image artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v6
with:
name: gateway-image-${{ github.sha }}
path: ${{ runner.temp }}/gateway-image.tar
publish-image:
runs-on: ubuntu-24.04
needs:
- check
- test
- test-docker
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
actions: read
packages: write
steps:
- name: Download production image artifact
uses: actions/download-artifact@v6
with:
name: gateway-image-${{ github.sha }}
path: ${{ runner.temp }}
- name: Log in to GitHub Container Registry
run: |
printf '%s' "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username "${{ github.actor }}" --password-stdin
- name: Publish tested image
run: |
docker load --input "${{ runner.temp }}/gateway-image.tar"
docker tag reference-gateway ghcr.io/${{ github.repository }}:latest
docker push ghcr.io/${{ github.repository }}:latest