-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (70 loc) · 2.42 KB
/
build-docker-images.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
name: Build and publish Docker Images
on:
push:
branches: [ "master" ]
# paths:
# - 'docker/enclave-base/**'
# - 'docker/parent-base/**'
pull_request:
branches: [ "master" ]
# types:
# - closed
# - opened
# paths:
# - 'docker/enclave-base/**'
# - 'docker/parent-base/**'
jobs:
build-docker-images:
runs-on: ubuntu-20.04
# if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'edited')
steps:
- name: Pull main repository
uses: actions/checkout@v3
with:
repository: fortanix/salmiac
- name: Build docker images
run: |
cd docker/enclave-base
TAG=$(cat tag)
docker build -t fortanix/enclave-base:$TAG .
docker save -o /tmp/enclave-base.tar fortanix/enclave-base
cd ../parent-base
TAG=$(cat tag)
docker build -t fortanix/parent-base:$TAG .
docker save -o /tmp/parent-base.tar fortanix/parent-base
- name: Upload enclave-base artifact
uses: actions/upload-artifact@v3
with:
name: enclave-base
path: /tmp/enclave-base.tar
- name: Upload parent-base artifact
uses: actions/upload-artifact@v3
with:
name: parent-base
path: /tmp/parent-base.tar
push-docker-images:
runs-on: ubuntu-20.04
needs: build-docker-images
# if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
steps:
- name: Download enclave-base artifact
uses: actions/download-artifact@v3
with:
name: enclave-base
path: /tmp/enclave-base
- name: Download parent-base artifact
uses: actions/download-artifact@v3
with:
name: parent-base
path: /tmp/parent-base
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PAT }}
- name: Load and push docker images
run: |
enclave_base_load_output=$(docker load --input /tmp/enclave-base/enclave-base.tar)
parent_base_load_output=$(docker load --input /tmp/parent-base/parent-base.tar)
docker push $(echo $enclave_base_load_output | awk '{print $3}')
docker push $(echo $parent_base_load_output | awk '{print $3}')