-
-
Notifications
You must be signed in to change notification settings - Fork 9
92 lines (83 loc) · 2.84 KB
/
service_docker-build-and-publish.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
85
86
87
88
89
90
91
92
name: Build and Publish Docker Images
on:
workflow_call:
inputs:
release_type:
type: string
required: true
description: 'Release type (latest, beta, edge, dev, etc)'
default: 'edge'
version:
type: string
required: false
description: 'Version to build (e.g. 1.0.0)'
default: "${{ github.ref_name }}"
ref_type:
type: string
required: false
description: 'Trigger type (tag or branch)'
default: "${{ github.ref_type }}"
ref:
type: string
required: false
description: 'Ref to build (e.g. v1.0.0)'
default: ''
jobs:
build-and-push:
runs-on: ubuntu-24.04
steps:
- name: Check out code.
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set REPOSITORY_BUILD_VERSION
id: set_version
run: |
if [ "${{ inputs.ref_type }}" == "tag" ]; then
echo "🚀 Setting REPOSITORY_BUILD_VERSION to Tag"
echo "REPOSITORY_BUILD_VERSION=${{ inputs.version }}-${{ github.run_id }}" >> $GITHUB_ENV
else
echo "👨🔬 Setting REPOSITORY_BUILD_VERSION to GIT Short SHA and GitHub Run ID"
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
echo "REPOSITORY_BUILD_VERSION=git-${SHORT_SHA}-${{ github.run_id }}" >> $GITHUB_ENV
fi
- name: "📦 Assemble the Docker Tags"
run: |
if [ "${{ inputs.ref_type }}" == "tag" ]; then
bash build.sh \
--release-type ${{ inputs.release_type }} \
--version ${{ inputs.version }} \
--print-tags-only
else
bash build.sh \
--release-type ${{ inputs.release_type }} \
--print-tags-only
fi
- name: Build and push
uses: docker/build-push-action@v6
with:
file: src/Dockerfile
cache-from: type=gha,mode=max
cache-to: type=gha,mode=max
platforms: |
linux/amd64
linux/arm64/v8
pull: true
push: true
tags: ${{ env.DOCKER_TAGS }}
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Run SSH anywhere with the power of Docker