-
Notifications
You must be signed in to change notification settings - Fork 4
115 lines (99 loc) · 3.18 KB
/
statistician-image.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
name: Statistician Test and Push
env:
IMAGE_NAME: opendatacube/datacube-statistician
on:
pull_request:
paths:
- 'docker/**'
- '!docker/readme.md'
push:
branches:
- develop
paths:
- 'docker/**'
- '!docker/readme.md'
workflow_run:
workflows: ["Publish to S3 and PyPI"]
branches: [develop]
types:
- completed
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
packages: write # This is required for pushing to ghcr
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: lint Dockerfile
uses: hadolint/[email protected]
with:
dockerfile: docker/Dockerfile
ignore: DL3008,DL3002,DL3013,DL3059,SC2102
- name: Build Statistician image
timeout-minutes: 20
shell: bash
run: |
cd docker
docker compose build
- name: Run Dockerized Tests for Statistician
shell: bash
run: |
cd docker
make test
set_tags:
if: github.ref == 'refs/heads/develop'
&& (github.event_name == 'push' || (github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success'))
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build a new docker image with tag
id: tag-image
run: |
echo "TAG=dev$(git rev-parse --short HEAD)" \
>> $GITHUB_OUTPUT
outputs:
image_tag: ${{ steps.tag-image.outputs.TAG }}
push_ecr:
if: github.ref == 'refs/heads/develop'
&& (needs.set_tags.outputs.image_tag)
needs: [test, set_tags]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::538673716275:role/github-actions-role
aws-region: ap-southeast-2
- name: Push image to ECR
uses: whoan/docker-build-with-cache-action@master
with:
context: ./docker
registry: 538673716275.dkr.ecr.ap-southeast-2.amazonaws.com
image_name: ${{ env.IMAGE_NAME }}
image_tag: latest,${{ needs.set_tags.outputs.image_tag }}
build_extra_args: '{"--build-arg": "UPDATE_VERSION=${{ needs.set_tags.outputs.image_tag }}"}'
push_public:
if: github.ref == 'refs/heads/develop'
&& (needs.set_tags.outputs.image_tag)
needs: [test, set_tags]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Push image to ghcr
uses: whoan/docker-build-with-cache-action@master
with:
context: ./docker
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image_name: ${{ github.repository }}
image_tag: latest,${{ needs.set_tags.outputs.image_tag }}
build_extra_args: '{"--build-arg": "UPDATE_VERSION=${{ needs.set_tags.outputs.image_tag }}"}'