-
Notifications
You must be signed in to change notification settings - Fork 12
125 lines (102 loc) · 4.22 KB
/
Copy pathbuild.yaml
File metadata and controls
125 lines (102 loc) · 4.22 KB
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
name: Build Docker image
permissions:
contents: read
on:
push:
schedule:
- cron: "0 4 * * 0"
jobs:
build_push_to_dockerhub:
strategy:
matrix:
base_container: ["php:7.4-bullseye", "php:8.0-bullseye", "php:8.1-bullseye", "php:8.2-bookworm", "php:8.3-bookworm", "php:8.4-bookworm"]
runs-on: ubuntu-latest
steps:
# no need to use actions/checkout with docker/build-push-action workflow
# https://github.com/docker/build-push-action
## Set environment variables for the build container by matrix
# 7.4 is the current "latest" default version and gets this extra tag
# upon EOL, this should move to 8.0
# 7.4 has already reached EoL, we can consider 8.0 as default version now
- name: Set PHP 7.4 settings
if: ${{ matrix.base_container == 'php:7.4-bullseye' }}
run: |
echo "BUILD_TAGS=10up/wordpress-ci:latest,10up/wordpress-ci:php-7.4" >> $GITHUB_ENV
echo "COMPOSER_VERSION=1" >> $GITHUB_ENV
- name: Set PHP 8.0 settings
if: ${{ matrix.base_container == 'php:8.0-bullseye' }}
run: |
echo "BUILD_TAGS=10up/wordpress-ci:php-8.0" >> $GITHUB_ENV
echo "COMPOSER_VERSION=2" >> $GITHUB_ENV
- name: Set PHP 8.1 settings
if: ${{ matrix.base_container == 'php:8.1-bullseye' }}
run: |
echo "BUILD_TAGS=10up/wordpress-ci:php-8.1" >> $GITHUB_ENV
echo "COMPOSER_VERSION=2" >> $GITHUB_ENV
- name: Set PHP 8.2 settings
if: ${{ matrix.base_container == 'php:8.2-bookworm' }}
run: |
echo "BUILD_TAGS=10up/wordpress-ci:php-8.2" >> $GITHUB_ENV
echo "COMPOSER_VERSION=2" >> $GITHUB_ENV
- name: Set PHP 8.3 settings
if: ${{ matrix.base_container == 'php:8.3-bookworm' }}
run: |
echo "BUILD_TAGS=10up/wordpress-ci:php-8.3" >> $GITHUB_ENV
echo "COMPOSER_VERSION=2" >> $GITHUB_ENV
- name: Set PHP 8.4 settings
if: ${{ matrix.base_container == 'php:8.4-bookworm' }}
run: |
echo "BUILD_TAGS=10up/wordpress-ci:php-8.4" >> $GITHUB_ENV
echo "COMPOSER_VERSION=2" >> $GITHUB_ENV
## GitHub Action validation testing before starting workflow ##
- name: Ensure Docker token is present
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
if: ${{ env.DOCKERHUB_TOKEN == '' }}
run: |
echo "Dockerhub token is not defined in GitHub secrets, exiting run"
exit 1
- name: Ensure Docker username is present
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
if: ${{ env.DOCKERHUB_USERNAME == '' }}
run: |
echo "Dockerhub username is not defined in GitHub secrets, exiting run"
exit 1
## Begin workflow ##
# https://github.com/marketplace/actions/docker-setup-qemu
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# https://github.com/marketplace/actions/docker-login
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# https://github.com/marketplace/actions/retry-action
# Never use cache with builds, build from scratch for security updates
- name: Retry action for Docker build
uses: Wandalen/wretry.action@v3
with:
action: docker/build-push-action@v6
attempt_limit: 3
attempt_delay: 30
with: |
push: false # set to false for testing
no-cache: true
tags: ${{ env.BUILD_TAGS }}
build-args: |
PHP_IMG=${{ matrix.base_container }}
COMPOSER_VERSION=${{ env.COMPOSER_VERSION }}
- name: Push Docker images
uses: docker/build-push-action@v6
if: ${{ github.ref == 'refs/heads/trunk' }}
with:
push: true
tags: ${{ env.BUILD_TAGS }}
build-args: |
PHP_IMG=${{ matrix.base_container }}
COMPOSER_VERSION=${{ env.COMPOSER_VERSION }}