-
Notifications
You must be signed in to change notification settings - Fork 5
110 lines (94 loc) · 2.91 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
110
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: ["*"]
pull_request:
jobs:
checks-update:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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@v4
- name: Check hadolint
run: |
hadolint */Dockerfile
checks-shfmt:
runs-on: ubuntu-latest
permissions:
contents: read
container: mvdan/shfmt:latest-alpine
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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@v4
- name: Check shellcheck
run: |
shellcheck update.sh
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
version: ["3.57", "3"]
needs: [checks-hadolint, checks-shfmt, checks-shellcheck, checks-update]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ekreative/php-cs-fixer
tags: |
type=raw,value=${{ matrix.version }}
flavor: |
latest=${{ toJSON(matrix.version == '3' && github.ref == 'refs/heads/main') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.version }}
# Build for Linux and Apple Silicon processors
platforms: linux/amd64,linux/arm64,linux/arm64/v8
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max