-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (67 loc) · 2.67 KB
/
docker-base-images-gha.yaml
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
name: docker-base-images-gha
on: workflow_dispatch
jobs:
build-base-images-gha:
strategy:
fail-fast: false
matrix:
IMAGE: [ pangeo-notebook, pangeo-notebook-shared, pytorch-notebook, r-notebook, k8s-hub, nasa-veda-singleuser-init ]
env:
REGISTRY_BASE_URL: public.ecr.aws/i8x6m1u9
name: ${{ matrix.IMAGE }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 3
token: ${{ secrets.GITHUB_TOKEN }}
- uses: sergeysova/jq-action@v2
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.DEPLOY_USER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOY_USER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: create ecr repository if not
uses: int128/create-ecr-repository-action@v1
with:
repository: ${{ matrix.IMAGE }}
public: true
- name: set the tags for docker
id: tags
run: |
DATESTR=$(date +%F)
datetag=${{ env.REGISTRY_BASE_URL }}/${{ matrix.IMAGE }}:$DATESTR
echo "datetag=${datetag}" >>$GITHUB_OUTPUT
DIGEST=$(sha256sum ./docker-images/base/${{ matrix.IMAGE }}/Dockerfile | cut -d' ' -f1)
digesttag=${{ env.REGISTRY_BASE_URL }}/${{ matrix.IMAGE }}:$DIGEST
echo "digesttag=${digesttag}" >>$GITHUB_OUTPUT
latesttag=${{ env.REGISTRY_BASE_URL }}/${{ matrix.IMAGE }}:latest
echo "latesttag=${latesttag}" >>$GITHUB_OUTPUT
- name: check for changes
id: changes
run: |
if ! git diff --quiet HEAD~ -- ./docker-images/base/${{ matrix.IMAGE }}; then
echo "./docker-images/base/${{ matrix.IMAGE }} changed, building!"
echo "build=true" >>$GITHUB_OUTPUT
else
echo "build=false" >>$GITHUB_OUTPUT
fi
- name: set up docker buildx
uses: docker/setup-buildx-action@v2
if: ${{ steps.changes.outputs.build == 'true' }}
- name: docker login for ecr
run:
aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws
if: ${{ steps.changes.outputs.build == 'true' }}
- name: docker build image
id: docker_build
uses: docker/build-push-action@v3
with:
push: true
context: ./docker-images/base/${{ matrix.IMAGE }}
tags: |
${{ steps.tags.outputs.datetag }}
${{ steps.tags.outputs.digesttag }}
${{ steps.tags.outputs.latesttag }}
if: ${{ steps.changes.outputs.build == 'true' }}