-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (57 loc) · 2.08 KB
/
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
60
61
62
63
64
65
66
67
name: "Build"
on:
push:
branches:
- "**"
tags:
- "**"
jobs:
docker-image:
name: "Docker image"
runs-on: ubuntu-latest
steps:
- name: "Define the Docker image version"
id: image_version
run: |
if [[ "${GITHUB_REF}" =~ 'refs/tags/' ]]
then
echo DEFAULT_IMAGE_VERSION=${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT
echo ALPINE_IMAGE_VERSION=${GITHUB_REF#refs/tags/}-alpine >> $GITHUB_OUTPUT
else
echo DEFAULT_IMAGE_VERSION=latest >> $GITHUB_OUTPUT
echo ALPINE_IMAGE_VERSION=alpine >> $GITHUB_OUTPUT
fi
if [[ "${{ github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/') }}" == true ]]
then
BUILD_OUTPUT="registry"
else
BUILD_OUTPUT="cacheonly"
fi
echo BUILD_OUTPUT=${BUILD_OUTPUT} >> $GITHUB_OUTPUT
- name: "Checkout"
uses: actions/checkout@v4
- name: "Login to DockerHub"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: "xstefanox/remote-arm"
- name: "Build and push / default"
uses: docker/build-push-action@v6
with:
tags: ${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.image_version.outputs.DEFAULT_IMAGE_VERSION }}
platforms: linux/amd64,linux/arm64
target: default
outputs: type=${{ steps.image_version.outputs.BUILD_OUTPUT }}
- name: "Build and push / Alpine"
uses: docker/build-push-action@v6
with:
tags: ${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.image_version.outputs.ALPINE_IMAGE_VERSION }}
platforms: linux/amd64,linux/arm64
target: alpine
outputs: type=${{ steps.image_version.outputs.BUILD_OUTPUT }}