-
Notifications
You must be signed in to change notification settings - Fork 11
99 lines (81 loc) · 3.32 KB
/
build.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
name: Build Docker image
on:
push:
branches:
- "trunk"
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-bullseye", "php:8.3-bullseye"]
runs-on: ubuntu-20.04
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
# Oct 10, 2023 - NOTE: https://tenup.teamwork.com/app/tasks/19362336
# 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-bullseye' }}
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-bullseye' }}
run: |
echo "BUILD_TAGS=10up/wordpress-ci:php-8.3" >> $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 ##
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Never use cache with builds, build from scratch for security updates
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
push: true
no-cache: true
tags: ${{ env.BUILD_TAGS }}
build-args: |
PHP_IMG=${{ matrix.base_container }}
COMPOSER_VERSION=${{ env.COMPOSER_VERSION }}