1313 # Runs on Push
1414 push :
1515
16+ env :
17+ MATRIX_VERSION : ' ["8.1"]'
18+ MATRIX_ARCH : ' ["linux/amd64","linux/386","linux/arm64","linux/arm/v7","linux/arm/v6"]'
19+
1620
1721jobs :
1822
1923 # -----------------------------------------------------------------------------------------------
20- # Job (1/2): BUILD
24+ # Job (1/3): Configure Pipeline
25+ # -----------------------------------------------------------------------------------------------
26+ configure :
27+ name : Configure
28+ runs-on : ubuntu-latest
29+ outputs :
30+ matrix_version : ${{ steps.set-matrix-version.outputs.matrix_version }}
31+ matrix_arch : ${{ steps.set-matrix-arch.outputs.matrix_arch }}
32+ manifest_arch : ${{ steps.set-manifest-arch.outputs.manifest }}
33+ steps :
34+
35+ - name : " [OUTPUT] Export Matrix 'Version'"
36+ id : set-matrix-version
37+ run : |
38+ echo '::set-output name=matrix_version::${{ env.MATRIX_VERSION }}'
39+ echo "${{ env.MATRIX_VERSION }}"
40+
41+ - name : " [OUTPUT] Export Matrix 'Arch'"
42+ id : set-matrix-arch
43+ run : |
44+ echo '::set-output name=matrix_arch::${{ env.MATRIX_ARCH }}'
45+ echo "${{ env.MATRIX_ARCH }}"
46+
47+ - name : " [OUTPUT] Export Manifest 'Arch'"
48+ id : set-manifest-arch
49+ run : |
50+ ARCH="$( echo ${{ env.MATRIX_ARCH }} | sed 's/"//g' | sed 's/\[//g' | sed 's/\]//g' | sed 's/ //g' )"
51+ echo "::set-output name=manifest::${ARCH}"
52+ echo "${ARCH}"
53+
54+
55+ # -----------------------------------------------------------------------------------------------
56+ # Job (2/3): BUILD
2157 # -----------------------------------------------------------------------------------------------
2258 build :
23- name : " [ PHP-${{ matrix.version }} (${{ matrix.arch }}) ]"
59+ needs : configure
60+ name : Build PHP-${{ matrix.version }} (${{ matrix.arch }})
2461 runs-on : ubuntu-latest
2562 strategy :
2663 fail-fast : false
2764 matrix :
2865 version :
29- - ' 8.1 '
66+ - ${{ fromJson(needs.configure.outputs.matrix_version) }}
3067 arch :
31- - ' linux/amd64'
32- - ' linux/arm64'
33- - ' linux/386'
34- - ' linux/arm/v7'
35- - ' linux/arm/v6'
68+ - ${{ fromJson(needs.configure.outputs.matrix_arch) }}
3669 steps :
37-
3870 # ------------------------------------------------------------
3971 # Setup repository
4072 # ------------------------------------------------------------
@@ -51,37 +83,31 @@ jobs:
5183
5284 - name : " [SETUP] Determine Docker tag"
5385 id : tag
54- uses : cytopia/docker-tag@v0.3
86+ uses : cytopia/docker-tag-action @v0.4.7
5587
5688 # ------------------------------------------------------------
5789 # Build
5890 # ------------------------------------------------------------
5991 - name : Build
60- 92+ 6193 with :
6294 command : |
63- make build ARCH=${ARCH}
64- env :
65- ARCH : ${{ matrix.arch }}
95+ make build ARCH=${{ matrix.arch }}
6696
6797 # ------------------------------------------------------------
6898 # Test
6999 # ------------------------------------------------------------
70100 - name : " [TEST] Docker Image"
71- 101+ 72102 with :
73103 command : |
74- make test ARCH=${ARCH}
75- env :
76- ARCH : ${{ matrix.arch }}
104+ make test ARCH=${{ matrix.arch }}
77105
78106 - name : " [TEST] Update README"
79- 107+ 80108 with :
81109 command : |
82- make update-readme ARCH=${ARCH}
83- env :
84- ARCH : ${{ matrix.arch }}
110+ make update-readme ARCH=${{ matrix.arch }}
85111
86112 - name : " [TEST] Verify README"
87113 run : |
@@ -90,19 +116,26 @@ jobs:
90116 # ------------------------------------------------------------
91117 # Deploy
92118 # ------------------------------------------------------------
93- - name : " [DEPLOY] Login"
119+ - name : " [DEPLOY] Login (only repo owner) "
94120 uses : docker/login-action@v1
95121 with :
96122 username : ${{ secrets.DOCKERHUB_USERNAME }}
97123 password : ${{ secrets.DOCKERHUB_PASSWORD }}
124+ # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
125+ if : github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
126+ && (
127+ (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
128+ ||
129+ (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
130+ ||
131+ (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
132+ )
98133
99134 - name : " [DEPLOY] Publish architecture image (only repo owner)"
100- 135+ 101136 with :
102137 command : |
103- make push-arch TAG=${{ steps.tag.outputs.docker-tag }} ARCH=${ARCH}
104- env :
105- ARCH : ${{ matrix.arch }}
138+ make push-arch TAG=${{ steps.tag.outputs.docker-tag }} ARCH=${{ matrix.arch }}
106139 # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
107140 if : github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
108141 && (
@@ -114,19 +147,27 @@ jobs:
114147 )
115148
116149 # -----------------------------------------------------------------------------------------------
117- # Job (2/2 ): DEPLOY
150+ # Job (3/3 ): DEPLOY
118151 # -----------------------------------------------------------------------------------------------
119152 deploy :
120- needs : [build]
153+ needs : [configure, build]
121154 name : Deploy
122155 runs-on : ubuntu-latest
123156 strategy :
124157 fail-fast : false
125158 matrix :
126159 version :
127- - ' 8.1'
160+ - ${{ fromJson(needs.configure.outputs.matrix_version) }}
161+ # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
162+ if : github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
163+ && (
164+ (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
165+ ||
166+ (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
167+ ||
168+ (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
169+ )
128170 steps :
129-
130171 # ------------------------------------------------------------
131172 # Setup repository
132173 # ------------------------------------------------------------
@@ -137,7 +178,7 @@ jobs:
137178
138179 - name : " [SETUP] Determine Docker tag"
139180 id : tag
140- uses : cytopia/docker-tag@v0.3
181+ uses : cytopia/docker-tag-action @v0.4.7
141182
142183 # ------------------------------------------------------------
143184 # Deploy
@@ -149,22 +190,13 @@ jobs:
149190 password : ${{ secrets.DOCKERHUB_PASSWORD }}
150191
151192 - name : " [DEPLOY] Create Docker manifest"
152- 193+ 153194 with :
154195 command : |
155- make manifest-create TAG=${{ steps.tag.outputs.docker-tag }} ARCH="linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6 "
196+ make manifest-create TAG=${{ steps.tag.outputs.docker-tag }} ARCH="${{ needs.configure.outputs.manifest_arch }} "
156197
157- - name : " [DEPLOY] Publish Docker manifest (only repo owner) "
158- 198+ - name : " [DEPLOY] Publish Docker manifest"
199+ 159200 with :
160201 command : |
161202 make manifest-push TAG=${{ steps.tag.outputs.docker-tag }}
162- # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
163- if : github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
164- && (
165- (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
166- ||
167- (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')))
168- ||
169- (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-'))
170- )
0 commit comments