-
-
Notifications
You must be signed in to change notification settings - Fork 100
88 lines (78 loc) · 3.04 KB
/
docker.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
name: Docker
on:
push:
branches: [ main ]
pull_request: ~
schedule:
# Do not make it the first of the month and/or midnight since it is a very busy time
- cron: "* 10 5 * *"
release:
types: [ created ]
permissions:
contents: read
packages: write
jobs:
docker-build:
runs-on: ubuntu-20.04
name: Publish the Docker image ${{ matrix.name }}
# See https://github.com/phpstan/phpstan/commit/4a535193101975e50fbaeea92ca6eca8c7a349b1
concurrency: docker-build-${{ github.ref }}-${{ matrix.docker-file }}
strategy:
fail-fast: false
matrix:
include:
- name: PHP 7.2.5
docker-file: .docker/php725
image-tag: ghcr.io/box-project/box_php725
- name: PHP 8.1
docker-file: .docker/php81
image-tag: ghcr.io/box-project/box_php81
- name: PHP 8.1 (Xdebug)
docker-file: .docker/php81_xdebug
image-tag: ghcr.io/box-project/box_php81_xdebug
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
context: .
file: ${{ matrix.docker-file }}
platforms: linux/amd64
tags: ${{ matrix.image-tag }}
load: true
- name: Test the image
run: docker run --rm ${{ matrix.image-tag }} php --version
- name: Build and push
if: ${{ github.ref_name == 'main' }}
uses: docker/build-push-action@v3
with:
context: .
file: ${{ matrix.docker-file }}
platforms: linux/amd64
tags: ${{ matrix.image-tag }}
push: true
# See https://github.com/phpstan/phpstan/pull/7373/files
# for the scope.
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, scope=${{ github.workflow }}
# This is a "trick", a meta task which does not change, and we can use in
# the protected branch rules as opposed to the tests one above which
# may change regularly.
validate-images:
name: Docker status
runs-on: ubuntu-latest
needs: docker-build
if: always()
steps:
- run: exit 0