Skip to content

Commit 997a4af

Browse files
authored
Merge pull request #358 from The-Strategy-Unit/alter-schema-deploy
alter schema deploy
2 parents 6f49837 + 525a91e commit 997a4af

File tree

7 files changed

+98
-93
lines changed

7 files changed

+98
-93
lines changed

.github/workflows/build_container.yaml

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
on:
22
workflow_call:
33
inputs:
4+
docker-tag:
5+
required: true
6+
default: dev
7+
type: string
48
app-version:
59
required: true
6-
type: string
10+
default: dev
11+
type: string
712
data-version:
813
required: true
14+
default: dev
915
type: string
1016
latest:
1117
required: false
@@ -24,27 +30,8 @@ on:
2430
required: true
2531

2632
jobs:
27-
get-version:
28-
runs-on: ubuntu-latest
29-
env:
30-
# replaced progamatically if deploying to production
31-
VERSION: dev
32-
outputs:
33-
version: ${{ steps.set-outputs.outputs.VERSION }}
34-
steps:
35-
- name: Update version (production)
36-
if: ${{ inputs.latest }}
37-
run: |
38-
VERSION=`echo ${{ inputs.app-version }} | awk 'BEGIN { FS="."; } { print ""$1"."$2; }'`
39-
echo "VERSION=$VERSION" >> $GITHUB_ENV
40-
41-
- name: Set outputs
42-
id: set-outputs
43-
run: echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
44-
4533
build-and-deploy-ghcr:
4634
runs-on: ubuntu-latest
47-
needs: [get-version]
4835
steps:
4936
- name: 'Checkout GitHub Action'
5037
uses: actions/checkout@v4
@@ -62,23 +49,22 @@ jobs:
6249
6350
- name: 'Build image'
6451
run: |
65-
docker build . -t ghcr.io/the-strategy-unit/nhp_model:${{ needs.get-version.outputs.version }} \
52+
docker build . -t ghcr.io/the-strategy-unit/nhp_model:${{ inputs.docker-tag }} \
6653
--build-arg app_version=${{ inputs.app-version }} \
6754
--build-arg data_version=${{ inputs.data-version }}
6855
6956
- name: 'Push image'
7057
run: |
71-
docker push ghcr.io/the-strategy-unit/nhp_model:${{ needs.get-version.outputs.version }}
58+
docker push ghcr.io/the-strategy-unit/nhp_model:${{ inputs.docker-tag }}
7259
7360
- name: 'Push latest'
7461
if: ${{ inputs.latest }}
7562
run: |
76-
docker tag ghcr.io/the-strategy-unit/nhp_model:${{ needs.get-version.outputs.version }} ghcr.io/the-strategy-unit/nhp_model:latest
63+
docker tag ghcr.io/the-strategy-unit/nhp_model:${{ inputs.docker-tag }} ghcr.io/the-strategy-unit/nhp_model:latest
7764
docker push ghcr.io/the-strategy-unit/nhp_model:latest
7865
7966
build-and-deploy-acr:
8067
runs-on: ubuntu-latest
81-
needs: [get-version]
8268
steps:
8369
- name: 'Checkout GitHub Action'
8470
uses: actions/checkout@v4
@@ -102,17 +88,17 @@ jobs:
10288
- name: 'Build and push image'
10389
run: |
10490
# include the storage account env var for the data for acr
105-
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ needs.get-version.outputs.version }} \
91+
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ inputs.docker-tag }} \
10692
--build-arg app_version=${{ inputs.app-version }} \
10793
--build-arg data_version=${{ inputs.data-version }} \
10894
--build-arg storage_account=${{ secrets.NHP_STORAGE_ACCOUNT }}
10995
11096
- name: 'Push image'
11197
run: |
112-
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ needs.get-version.outputs.version }}
98+
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ inputs.docker-tag }}
11399
114100
- name: 'Push latest'
115101
if: ${{ inputs.latest }}
116102
run: |
117-
docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ needs.get-version.outputs.version }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
103+
docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ inputs.docker-tag }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
118104
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Deploy schema.json to GitHub Pages
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
schema-tag:
7+
required: true
8+
default: dev
9+
type: string
10+
11+
permissions:
12+
pages: write
13+
id-token: write
14+
contents: write
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Clone existing schemas branch content
24+
run: |
25+
git fetch --depth=1 origin schemas
26+
git worktree add schemas schemas
27+
28+
- name: Copy schema to app version path
29+
run: |
30+
mkdir schemas/${{ inputs.schema-tag }}
31+
cp params-schema.json schemas/${{ inputs.schema-tag }}/
32+
33+
- name: Commit the schema
34+
run: |
35+
git config user.name "github-actions[bot]"
36+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
37+
cd schemas
38+
git add .
39+
git commit -m "adding schema for ${{ inputs.schema-tag }}"
40+
git push origin schemas
41+
42+
- name: Upload to GitHub Pages
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: schemas
46+
47+
deploy:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
environment:
51+
name: github-pages
52+
url: ${{ steps.deployment.outputs.page_url }}
53+
steps:
54+
- name: Deploy to GitHub Pages
55+
id: deployment
56+
uses: actions/deploy-pages@v4

.github/workflows/deploy_dev.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ jobs:
1010
deploy-dev-model:
1111
uses: ./.github/workflows/build_container.yaml
1212
with:
13-
app-version: dev
13+
docker-tag: dev
14+
app-version: dev
1415
data-version: dev
16+
latest: false
1517
secrets: inherit
1618

1719
deploy-dev-schema:
18-
uses: ./.github/workflows/deploy_schema.yaml
19-
with:
20-
app-version: dev
20+
uses: ./.github/workflows/build_schema.yaml
21+
with:
22+
schema-tag: dev
2123
secrets: inherit

.github/workflows/deploy_release.yaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,33 @@ on:
66
name: Deploy Production
77

88
jobs:
9+
10+
set-tag:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
tag: ${{ steps.create-tag.outputs.TAG }}
14+
15+
steps:
16+
- name: Create tag
17+
id: create-tag
18+
run: |
19+
TAG=`echo ${{ github.ref_name }} | awk 'BEGIN { FS="."; } { print ""$1"."$2; }'`
20+
echo "TAG=$TAG" >> $$GITHUB_OUTPUT
21+
922
deploy-production:
23+
needs: [set-tag]
1024

1125
uses: ./.github/workflows/build_container.yaml
1226
with:
13-
app-version: ${{github.ref_name}}
27+
docker-tag: ${{ needs.set-tag.outputs.tag }}
28+
app-version: ${{ github.ref_name }}
1429
data-version: ${{vars.data_version}}
1530
latest: true
1631
secrets: inherit
1732

1833
deploy-schema:
34+
needs: [set-tag]
1935

20-
uses: ./.github/workflows/deploy_schema.yaml
36+
uses: ./.github/workflows/build_schema.yaml
2137
with:
22-
app-version: ${{github.ref_name}}
38+
schema-tag: ${{ needs.set-tag.outputs.tag }}

.github/workflows/deploy_schema.yaml

Lines changed: 0 additions & 58 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,7 @@ _targets*/
7878

7979
# override the data rule for model/data
8080
!model/data
81-
!tests/data
81+
!tests/data
82+
83+
# ignore schemas/ this is a worktree
84+
schemas/

0 commit comments

Comments
 (0)