-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (69 loc) · 2.38 KB
/
build-images.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
name: Build Docker Images
permissions:
contents: read
packages: write
on:
push:
branches: [ main ]
paths-ignore:
- "README.md"
- "docker-compose.yml"
- "examples/**"
- ".run/**"
- ".circleci/**"
schedule:
- cron: "0 16 * * MON,WED,FRI"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php_version: ['8.3', '8.1', '8.0', '7.4']
variant: ['apache', 'apache-chrome']
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u ${{ secrets.DOCKER_HUB_USER }} --password-stdin
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Github Short SHA
run: |
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
- name: Set variables
run: |
if [ "${{ matrix.variant }}" == "apache" ]; then
echo "DOCKER_TAG=${{ matrix.php_version }}" >> $GITHUB_ENV
echo "DOCKER_FILE=Dockerfile" >> $GITHUB_ENV
elif [ "${{ matrix.variant }}" == "apache-chrome" ]; then
echo "DOCKER_TAG=${{ matrix.php_version }}-headless" >> $GITHUB_ENV
echo "DOCKER_FILE=Dockerfile-headless" >> $GITHUB_ENV
else
echo "Invalid variant: ${{ matrix.variant }}"
exit 1
fi
- name: Check if file exists
id: check_file
run: |
if [ -f "./${{ matrix.php_version }}/${{ env.DOCKER_FILE }}" ]; then
echo "file_exists=true" >> $GITHUB_ENV
else
echo "file_exists=false" >> $GITHUB_ENV
fi
- name: Build and push
uses: docker/build-push-action@v6
if: env.file_exists == 'true'
with:
context: .
file: ./${{ matrix.php_version }}/${{ env.DOCKER_FILE }}
tags:
ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }},
ghcr.io/${{ github.repository }}:${{ env.GITHUB_SHA_SHORT }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max