forked from cturra/docker-ntp
-
Notifications
You must be signed in to change notification settings - Fork 9
51 lines (49 loc) · 1.93 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
name: Deploy multi-architecture Docker images with buildx
on:
pull_request:
branches: master
push:
branches: master
tags: '*'
jobs:
buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare
id: prepare
run: |
IMAGE=simonrupf/chronyd
QEMU_PLATFORMS=linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
VERSION=${GITHUB_REF##*/}
echo "buildx_args=--tag ${IMAGE}:latest \
--tag ${IMAGE}:${VERSION} \
--platform linux/amd64,linux/386,${QEMU_PLATFORMS} ." >> $GITHUB_OUTPUT
echo "qemu_platforms=${QEMU_PLATFORMS}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ steps.prepare.outputs.qemu_platforms }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Docker Build
run: |
docker build --no-cache --pull --output "type=image,push=false" --build-arg BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%S%z') ${{ steps.prepare.outputs.buildx_args }}
- name: Docker Login
if: success() && github.event_name != 'pull_request' && github.ref != 'refs/heads/master'
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
printenv DOCKER_PASSWORD | docker login --username "${DOCKER_USERNAME}" --password-stdin
- name: Docker Push
if: success() && github.event_name != 'pull_request' && github.ref != 'refs/heads/master'
run: |
docker build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Cleanup
if: always() && github.event_name != 'pull_request' && github.ref != 'refs/heads/master'
run: |
rm -f ${HOME}/.docker/config.json