-
-
Notifications
You must be signed in to change notification settings - Fork 112
111 lines (93 loc) · 3.09 KB
/
deploy-docker.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
name: Deploy Docker images
on:
push:
branches:
- master
tags:
- '*' # On all tags
jobs:
matrix:
name: Find layers
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get the version
id: get-version
run: |
REF=${GITHUB_REF#refs/tags/}
if [[ $REF == *"refs"* ]]; then
REF=""
fi
echo ::set-output name=VERSION::$REF
# Only find layers that have changed since last tag OR if tag then get all
- id: find-layers
run: |
if [ "${{ steps.get-version.outputs.VERSION }}" = "" ]; then
git fetch --prune --unshallow
echo "::set-output name=list::$(git diff --name-only HEAD $(git describe --tags --abbrev=0) | grep layers/ | cut -d / -f 2 | sort | uniq | jq -R -s -c 'split("\n")[:-1]')"
else
echo "::set-output name=list::$(ls layers | jq -R -s -c 'split("\n")[:-1]')"
fi
outputs:
# Make the outputs accessible outside this job
list: ${{ steps.find-layers.outputs.list }}
version: ${{ steps.get-version.outputs.VERSION }}
publish:
needs: matrix
name: Deploy images
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: '1'
strategy:
fail-fast: false
matrix:
layer: ${{ fromJson(needs.matrix.outputs.list) }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
- name: Docker login
run: echo '${{ secrets.DOCKER_PASSWORD }}' | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build images
run: layer=${{ matrix.layer }} make docker-images
- name: Test images
run: layer=${{ matrix.layer }} make test
- name: Publish
env:
DOCKER_TAG: ${{ needs.matrix.outputs.version }}
run: layer=${{ matrix.layer }} make publish-docker-images
update:
needs: [matrix, publish]
name: Update tags
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
- name: Update tags
run: ./new-docker-tags.php ${{ needs.matrix.outputs.version }} --update
if: ${{ needs.matrix.outputs.version != '' }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
if: ${{ needs.matrix.outputs.version != '' }}
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
base: master
branch: tag-update
author: Bref Bot <[email protected]>
committer: Bref Bot <[email protected]>
commit-message: Adding tag ${{ needs.matrix.outputs.version }}
title: Update list of tags
body: |
Since we just tagged ${{ needs.matrix.outputs.version }} we also need to update config.json