-
Notifications
You must be signed in to change notification settings - Fork 5
109 lines (94 loc) · 3.01 KB
/
release-image.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
name: Create and publish a Docker image
# Cache setup: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md
# Multi push: https://github.com/docker/build-push-action/blob/master/docs/advanced/push-multi-registries.md
on:
push:
branches: ['*']
jobs:
checks-update:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check update has been run
run: |
./update.sh
git diff --quiet
checks-hadolint:
runs-on: ubuntu-latest
permissions:
contents: read
container: hadolint/hadolint:latest-debian
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check hadolint
run: |
hadolint --ignore DL3059 */Dockerfile
checks-shfmt:
runs-on: ubuntu-latest
permissions:
contents: read
container: mvdan/shfmt:latest-alpine
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check shfmt
run: |
shfmt -i 2 -ci -d update.sh
checks-shellcheck:
runs-on: ubuntu-latest
permissions:
contents: read
container: koalaman/shellcheck-alpine:latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check shellcheck
run: |
shellcheck update.sh
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
version: [ '7', '7.3', '7.4', '8', '8.0', '8.1', '8.3' ]
distro: ['', '-alpine']
debug: ['', '-xdebug']
exclude:
- distro: '-alpine'
debug: '-xdebug'
needs: [checks-hadolint, checks-shfmt, checks-shellcheck, checks-update]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ekreative/php
tags: |
type=raw,value=${{ matrix.version }}${{ matrix.distro }}${{ matrix.debug }}
flavor: |
latest=${{ toJSON(matrix.version == '8' && matrix.distro == '' && matrix.debug == '' && github.ref == 'refs/heads/master') }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ${{ matrix.version }}${{ matrix.distro }}${{ matrix.debug }}
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max