-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (74 loc) · 2.79 KB
/
build-push.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
83
84
name: build-push-ar
on:
workflow_call:
inputs:
dockerFile:
required: true
type: string
jobs:
build-push-ar:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
id-token: write
steps:
- uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # v4
- uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
with:
dockerfile: ${{ inputs.dockerFile }}
verbose: true
- name: Extract branch or tag name as docker tag
shell: bash
run: |-
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG=$(echo "${GITHUB_REF#refs/tags/}" | sed 's/[^a-zA-Z0-9._-]//g' | awk '{print substr($0, length($0)-120)}')
else
TAG=$(echo "${GITHUB_REF#refs/heads/}" | sed 's/[^a-zA-Z0-9._-]//g' | awk '{print substr($0, length($0)-120)}')
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
SHA=$(echo ${GITHUB_SHA} | cut -c1-7)
echo "sha=$SHA" >> $GITHUB_OUTPUT
id: extract_tag
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3
- name: Setup docker build
shell: bash
run: |-
# aka base build
if [ ${{ inputs.dockerFile }} == "Dockerfile" ]; then
echo "image=scyllaridae" >> $GITHUB_OUTPUT
echo "context=." >> $GITHUB_OUTPUT
exit 0
fi
DIR=$(dirname "${{ inputs.dockerFile }}")
echo "image=scyllaridae-$(basename $DIR)" >> $GITHUB_OUTPUT
echo "context=$DIR" >> $GITHUB_OUTPUT
id: setup
- name: Docker Hub Login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: 'docker.io'
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Determine platforms
id: determine-platforms
run: |
if [[ "${{steps.setup.outputs.image}}" == "scyllaridae-whisper" ]]; then
echo "DOCKER_PLATFORMS=linux/amd64" >> $GITHUB_ENV
else
echo "DOCKER_PLATFORMS=linux/amd64,linux/arm64" >> $GITHUB_ENV
fi
- name: Build and push dockerhub
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6
with:
context: ${{steps.setup.outputs.context}}
platforms: ${{ env.DOCKER_PLATFORMS }}
build-args: |
TAG=${{steps.extract_tag.outputs.tag}}
push: true
tags: |
lehighlts/${{steps.setup.outputs.image}}:${{steps.extract_tag.outputs.tag}}
lehighlts/${{steps.setup.outputs.image}}:${{steps.extract_tag.outputs.tag}}-${{steps.extract_tag.outputs.sha}}