-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (125 loc) · 4.12 KB
/
cd.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Build and deploy
on:
workflow_dispatch:
push:
concurrency:
group: cd-${{ github.ref }}
jobs:
check-dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: snok/install-poetry@v1
- name: Check Poetry dependencies
run: poetry show -o
# - name: Check npm dependencies
# run: |
# npm install
# npm outdated
# npm audit
test-node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/node-tests
test-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/python-tests
version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get tag
id: version-tag
uses: nationalarchives/ds-docker-actions/.github/actions/get-version-tag@main
outputs:
version: ${{ steps.version-tag.outputs.version-tag }}
build:
runs-on: ubuntu-latest
needs:
- test-python
- test-node
- check-dependencies
- version
permissions:
packages: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Build Docker image
uses: nationalarchives/ds-docker-actions/.github/actions/docker-build@main
with:
version: ${{ needs.version.outputs.version }}
latest: ${{ github.ref == 'refs/heads/main' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
docker-image-name: ${{ vars.DOCKER_IMAGE_NAME }}
- name: Create tag
if: github.ref == 'refs/heads/main'
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v${{ needs.version.outputs.version }}',
sha: context.sha
})
update-ds-infrastructure-web:
runs-on: ubuntu-latest
needs:
- build
- version
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
repository: nationalarchives/ds-infrastructure-web
ref: main
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
- name: Set up git config
run: |
git config user.name "ds-frontend"
git config user.email "<>"
- name: Install jq
run: sudo apt-get install jq
- name: Update config
run: jq --indent 4 '(.services.frontend.version|="${{ needs.version.outputs.version }}")' config/develop.json > tmp.$$.json && mv tmp.$$.json config/develop.json
- name: Push new version
run: |
git add config/develop.json
git commit -m "Update frontend to v${{ needs.version.outputs.version }}"
git push origin main
update-dblclk:
runs-on: ubuntu-latest
needs:
- build
- version
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
repository: nationalarchives/ds-etna
ref: proof-of-concept
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
- name: Set up git config
run: |
git config user.name "ds-frontend"
git config user.email "<>"
- name: Install yq
uses: dcarbone/[email protected]
- name: Update config
run: |
yq '(.services.frontend.image|="ghcr.io/${{ github.repository_owner }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ needs.version.outputs.version }}")' docker-compose.yml > tmp.$$.yml && mv tmp.$$.yml docker-compose.yml
yq '(.services.frontend-develop.image|="ghcr.io/${{ github.repository_owner }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ needs.version.outputs.version }}")' docker-compose.yml > tmp.$$.yml && mv tmp.$$.yml docker-compose.yml
- name: Push new version
run: |
git add docker-compose.yml
git commit -m "Update frontend to v${{ needs.version.outputs.version }}"
git push origin proof-of-concept