-
Notifications
You must be signed in to change notification settings - Fork 1
180 lines (161 loc) · 6.4 KB
/
build-docker-images.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Build Docker images
on:
push:
env:
PHPSTAN_VERSION: 1.11.2
DOCKER_REPOSITORY: aragon999/phpstan-shopware
CACHE_KEY: 2020-09-22
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- shopware-version: v6.4.0.0
php-version: "7.4"
- shopware-version: v6.4.1.2
php-version: "7.4"
- shopware-version: v6.4.2.1
php-version: "7.4"
- shopware-version: v6.4.3.1
php-version: "7.4"
- shopware-version: v6.4.4.1
php-version: "7.4"
- shopware-version: v6.4.5.1
php-version: "7.4"
- shopware-version: v6.4.6.1
php-version: "7.4"
- shopware-version: v6.4.7.0
php-version: "7.4"
- shopware-version: v6.4.8.2
php-version: "7.4"
- shopware-version: v6.4.9.0
php-version: "7.4"
- shopware-version: v6.4.10.1
php-version: "7.4"
- shopware-version: v6.4.11.1
php-version: "7.4"
- shopware-version: v6.4.12.0
php-version: "7.4"
- shopware-version: v6.4.13.0
php-version: "7.4"
- shopware-version: v6.4.14.0
php-version: "7.4"
- shopware-version: v6.4.15.2
php-version: "7.4"
- shopware-version: v6.4.16.1
php-version: "7.4"
- shopware-version: v6.4.17.2
php-version: "7.4"
- shopware-version: v6.4.18.1
php-version: "7.4"
- shopware-version: v6.4.19.0
php-version: "7.4"
- shopware-version: v6.4.20.2
php-version: "7.4"
- shopware-version: v6.5.0.0
php-version: "8.1"
- shopware-version: v6.5.1.1
php-version: "8.1"
- shopware-version: v6.5.2.1
php-version: "8.1"
- shopware-version: v6.5.3.3
php-version: "8.1"
- shopware-version: v6.5.4.1
php-version: "8.1"
- shopware-version: v6.5.5.2
php-version: "8.1"
- shopware-version: v6.5.6.1
php-version: "8.1"
- shopware-version: v6.5.7.4
php-version: "8.1"
- shopware-version: v6.5.8.10
php-version: "8.1"
- shopware-version: v6.6.0.3
php-version: "8.2"
- shopware-version: v6.6.1.2
php-version: "8.2"
- shopware-version: v6.6.2.0
php-version: "8.2"
steps:
- name: Clone
uses: actions/checkout@v4
- name: Get Tag
id: get-docker-tag
run: |
shopware_version_tag=$(echo "${{ matrix.shopware-version }}" | grep -m1 -E '(v[0-9]+\.[0-9]+\.[0-9]+)' -o)
[ "${shopware_version_tag}" == "" ] && exit 1
tag="${{ env.DOCKER_REPOSITORY }}:${shopware_version_tag}"
echo "Shopware version ${{ matrix.shopware-version }}"
echo "Image Tag: ${tag}"
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ env.CACHE_KEY }}-${{ env.PHPSTAN_VERSION }}-${{ matrix.shopware-version }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ env.CACHE_KEY }}-${{ env.PHPSTAN_VERSION }}-${{ matrix.shopware-version }}-
- name: Build docker image
uses: docker/build-push-action@v5
with:
build-args: |
PHPSTAN_VERSION=${{ env.PHPSTAN_VERSION }}
SHOPWARE_VERSION=${{ matrix.shopware-version }}
PHP_VERSION=${{ matrix.php-version }}
tags: ${{ steps.get-docker-tag.outputs.tag }}
push: false
load: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
- name: Run basic checks
run: |
# Check phpstan version of the image
docker run --rm ${{ steps.get-docker-tag.outputs.tag }} \
| grep "${PHPSTAN_VERSION}" || exit_code=$?
[[ "$exit_code" -ne "0" ]] \
&& docker run --rm ${{ steps.get-docker-tag.outputs.tag }} \
&& echo "Did not find expected phpstan version" \
&& exit ${exit_code}
# Check that phpstan has access to the shopware classes
docker run --rm ${{ steps.get-docker-tag.outputs.tag }} \
analyze --level 5 \
/composer/vendor/shopware/core/Content/Sitemap
- name: Check for push
id: check-push
run: |
if [ "${{ secrets.DOCKER_USERNAME }}" == "" ] || [ "${{ secrets.DOCKER_PASSWORD }}" == "" ]; then
echo "No Docker credentials found, skipping push."
exit 0
fi
if [ "${{ github.event_name == 'pull_request' }}" == "true" ]; then
echo "Pull request, skipping push."
exit 0
fi
if [ "${{ github.ref }}" != "refs/heads/master" ]; then
echo "Not on master branch, skipping push."
exit 0
fi
echo "push=true" >> $GITHUB_OUTPUT
- name: Login to Docker Hub Registry
uses: docker/login-action@v3
if: ${{ steps.check-push.outputs.push }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push docker image
if: ${{ steps.check-push.outputs.push }}
run: |
docker push ${{ steps.get-docker-tag.outputs.tag }}