-
Notifications
You must be signed in to change notification settings - Fork 2
59 lines (50 loc) Β· 2.46 KB
/
docker-build.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
name: Docker Image Push (on commit and base image update)
on:
push:
branches: [ "master" ]
schedule:
- cron: "30 */8 * * *"
env:
IMAGE_OWNER: kimbtechnologies
IMAGE_NAME: php_smtp_nginx
BASE_IMAGE: kimbtechnologies/php_nginx:latest
jobs:
build:
runs-on: ubuntu-latest
steps:
# check if update needed
- name: Check for new baseimage
id: check
uses: lucacome/docker-image-update-checker@v1
with:
base-image: "${{env.BASE_IMAGE}}"
image: "${{env.IMAGE_OWNER}}/${{env.IMAGE_NAME}}:latest"
if: github.event_name != 'push'
# setup build env.
- name: Access repository contents
uses: actions/checkout@v4
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
# build local AMD image
- name: Build the AMD image
run: docker build . --file "Dockerfile" --tag "$IMAGE_OWNER/$IMAGE_NAME:latest"
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
- name: Push tag 8-latest
run: docker tag "$IMAGE_OWNER/$IMAGE_NAME:latest" "$IMAGE_OWNER/$IMAGE_NAME:8-latest"; docker push "$IMAGE_OWNER/$IMAGE_NAME:8-latest";
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
# Multi platform support
- name: Set up QEMU for Docker Buildx
uses: docker/setup-qemu-action@v3
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
# Multi platform image build and push
- name: Build and push the ARM Docker images
run: php_v=$(docker run --rm "$IMAGE_OWNER/$IMAGE_NAME:latest" sh -c 'echo "$PHP_VERSION"'); php_v=$(echo $php_v | grep -o '[0-9\.]*'); docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/arm64 . --file "Dockerfile" --tag "$IMAGE_OWNER/$IMAGE_NAME:latest" --tag "$IMAGE_OWNER/$IMAGE_NAME:php-$php_v" --push
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}