forked from lalvarezguillen/monero
-
Notifications
You must be signed in to change notification settings - Fork 6
141 lines (110 loc) · 4.85 KB
/
dockerhub-publish.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
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
135
136
137
138
139
140
name: DockerHub Publish
on:
push:
branches: [ master, most_recent_tag ]
workflow_dispatch: # manual trigger (through website or api)
env:
IMAGE_NAME: rinocommunity/monero
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get latest Monero tag
run: |
echo "BUILD_BRANCH=$(curl -s https://api.github.com/repos/monero-project/monero/tags | grep -i name | awk 'NR==1{print $2}' | tr -d "\",")" >> $GITHUB_ENV
if: github.ref == 'refs/heads/most_recent_tag'
- name: Set source branch when using Monero tag
run: |
echo "CLONE_BRANCH=${{ env.BUILD_BRANCH }}" >> $GITHUB_ENV
if: github.ref == 'refs/heads/most_recent_tag'
- name: Get latest Monero master commit hash
run: |
echo "BUILD_BRANCH=$(curl -s https://api.github.com/repos/monero-project/monero/branches/master | grep -i sha | awk 'NR==1{print $2}' | tr -d "\",")" >> $GITHUB_ENV
if: github.ref == 'refs/heads/master'
- name: Set source branch when using master branch
run: |
echo "CLONE_BRANCH=master" >> $GITHUB_ENV
if: github.ref == 'refs/heads/master'
- name: Log into Dockerhub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull "dependencies1" if it exists
run: docker pull $IMAGE_NAME:dependencies1 || true
- name: Build updated "dependencies1" if necessary
run: docker build --pull
--target dependencies1
--cache-from $IMAGE_NAME:dependencies1
-f ./Dockerfile
-t $IMAGE_NAME:dependencies1 .
- name: Push "dependencies1"
run: docker push $IMAGE_NAME:dependencies1
- name: Pull "dependencies2" if it exists
run: docker pull $IMAGE_NAME:dependencies2 || true
- name: Build updated "dependencies2" if necessary
run: docker build --pull
--target dependencies2
--cache-from $IMAGE_NAME:dependencies1
--cache-from $IMAGE_NAME:dependencies2
-f ./Dockerfile
-t $IMAGE_NAME:dependencies2 .
- name: Push "dependencies2"
run: docker push $IMAGE_NAME:dependencies2
- name: Pull "dependencies3" if it exists
run: docker pull $IMAGE_NAME:dependencies3 || true
- name: Build updated "dependencies3" if necessaru
run: docker build --pull
--target dependencies3
--cache-from $IMAGE_NAME:dependencies1
--cache-from $IMAGE_NAME:dependencies2
--cache-from $IMAGE_NAME:dependencies3
-f ./Dockerfile
-t $IMAGE_NAME:dependencies3 .
- name: Push "dependencies3"
run: docker push $IMAGE_NAME:dependencies3
- name: Pull "builder" if it exists
run: docker pull $IMAGE_NAME:builder || true
- name: Build updated "builder" if necessary
run: docker build --pull
--target builder
--cache-from $IMAGE_NAME:dependencies1
--cache-from $IMAGE_NAME:dependencies2
--cache-from $IMAGE_NAME:dependencies3
--cache-from $IMAGE_NAME:builder
--build-arg BRANCH=${{ env.CLONE_BRANCH }}
--build-arg BUILD_BRANCH=${{ env.BUILD_BRANCH }}
-f ./Dockerfile
-t $IMAGE_NAME:builder .
- name: Push "builder"
run: docker push $IMAGE_NAME:builder
- name: Pull final image if it exists
run: docker pull $IMAGE_NAME || true
- name: Build updated final image if necessary
run: docker build --pull
--cache-from $IMAGE_NAME:dependencies1
--cache-from $IMAGE_NAME:dependencies2
--cache-from $IMAGE_NAME:dependencies3
--cache-from $IMAGE_NAME:builder
--cache-from $IMAGE_NAME
--build-arg BRANCH=${{ env.CLONE_BRANCH }}
--build-arg BUILD_BRANCH=${{ env.BUILD_BRANCH }}
-f ./Dockerfile
-t $IMAGE_NAME .
- name: Tag the image with its Monero tag and/or master branch commit hash
run: docker tag $IMAGE_NAME $IMAGE_NAME:${{ env.BUILD_BRANCH }}
- name: Push the image tagged with its Monero tag and/or master branch commit hash
run: docker push $IMAGE_NAME:${{ env.BUILD_BRANCH }}
- name: Tag the image with the most_recent_tag
run: docker tag $IMAGE_NAME $IMAGE_NAME:most_recent_tag
if: github.ref == 'refs/heads/most_recent_tag'
- name: Push the image tagged with the most recent monero project repo tag
run: docker push $IMAGE_NAME:most_recent_tag
if: github.ref == 'refs/heads/most_recent_tag'
- name: Push the latest image made from the most recent master commit
run: docker push $IMAGE_NAME:latest
if: github.ref == 'refs/heads/master'