-
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (122 loc) · 4.39 KB
/
docker-build-push.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
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
name: Docker CI/CD
on:
workflow_dispatch:
push:
branches:
- "v*"
- main
schedule:
- cron: "0 * * * *" # Runs hourly updates for the latest PHP versions and images
permissions:
packages: write
concurrency:
group: ${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name != 'schedule' }}
env:
SUPPORTED_PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
DEFAULT_IMAGE: "ghcr.io/ghostwriter/php"
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
container:
image: php:8.3-cli-alpine
steps:
- uses: actions/checkout@v4
- id: matrix
run: echo "matrix=$(php matrix.php)" >> $GITHUB_OUTPUT
production:
needs: [matrix]
runs-on: ubuntu-latest
continue-on-error: false
strategy:
fail-fast: true
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v3
with:
password: ${{ secrets.GHT }}
registry: ghcr.io
username: ${{ github.repository_owner }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
github-token: ${{ secrets.GHT }}
images: ${{ env.DEFAULT_IMAGE }}
tags: |
type=raw,value=${{ matrix.version }}-${{ matrix.variant }}
type=raw,value=latest,enable=${{ matrix.latest == matrix.version && matrix.variant == 'cli' }}
- name: Build and push PHP ${{ matrix.version }}
uses: docker/build-push-action@v6
with:
cache-from: type=gha,scope=${{ matrix.version }}-${{ matrix.variant }}
cache-to: type=gha,scope=${{ matrix.version }}-${{ matrix.variant }},mode=max
file: ${{ matrix.variant }}.Dockerfile
platforms: ${{ env.SUPPORTED_PLATFORMS}}
push: ${{ github.repository_owner == github.actor }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: PHP_VERSION=${{ matrix.version }}
development:
needs: [matrix, production]
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix.outputs.matrix)}}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v3
with:
password: ${{ secrets.GHT }}
registry: ghcr.io
username: ${{ github.repository_owner }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
github-token: ${{ secrets.GHT }}
images: ${{ env.DEFAULT_IMAGE }}
tags: type=raw,value=${{ matrix.version }}
- name: Build and push PHP ${{ matrix.version }} image
uses: docker/build-push-action@v6
with:
cache-from: type=gha,scope=${{ matrix.version }}
cache-to: type=gha,scope=${{ matrix.version }},mode=max
file: development.Dockerfile
platforms: ${{ env.SUPPORTED_PLATFORMS}}
push: ${{ github.repository_owner == github.actor }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: PHP_VERSION=${{ matrix.version }}