Skip to content

Commit c1293b1

Browse files
committed
Added github workflows
1 parent 89fde22 commit c1293b1

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

.github/workflows/build-image.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build target image
2+
on:
3+
workflow_call:
4+
inputs:
5+
registry:
6+
description: 'Docker Registry'
7+
required: true
8+
type: string
9+
default: 'ghcr.io'
10+
image:
11+
description: 'Image'
12+
required: true
13+
type: string
14+
version:
15+
description: 'Version'
16+
required: true
17+
type: string
18+
platform:
19+
description: 'Platform'
20+
required: true
21+
type: string
22+
arch:
23+
description: 'Architecture'
24+
required: true
25+
type: string
26+
jobs:
27+
build:
28+
name: Build
29+
runs-on: ${{ inputs.platform == 'linux' && (inputs.arch == 'arm64' || inputs.arch == 'arm') && 'self-hosted' || 'ubuntu-latest' }}
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
- name: Set tags
34+
id: tags
35+
run: |
36+
echo "image=${{ inputs.registry }}/${{ github.repository_owner }}/${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.arch }}" >> $GITHUB_OUTPUT
37+
echo "tag=${{ inputs.version }}" >> $GITHUB_OUTPUT
38+
- name: Login
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ${{ inputs.registry }}
42+
username: ${{ github.repository_owner }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
- name: Build
45+
run: |
46+
docker build \
47+
--tag ${{ steps.tags.outputs.image }}:${{ steps.tags.outputs.tag }} \
48+
--build-arg ARCH=${{ inputs.arch }} \
49+
--build-arg PLATFORM=${{ inputs.platform }} \
50+
--build-arg VERSION=${{ inputs.version }} \
51+
--file etc/docker/Dockerfile .
52+
- name: Push
53+
run: |
54+
docker push ${{ steps.tags.outputs.image }}:${{ steps.tags.outputs.tag }}

.github/workflows/make-images.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Make arm64 and amd64 docker images
2+
on:
3+
workflow_dispatch:
4+
5+
env:
6+
registry: ghcr.io
7+
image: coredns-nomad
8+
version: v1.11.1
9+
10+
jobs:
11+
build-images:
12+
strategy:
13+
matrix:
14+
platform: [ linux ]
15+
arch: [ arm64, amd64 ]
16+
uses: mutablelogic/go-coredns-nomad/.github/workflows/build-image.yaml@main
17+
with:
18+
registry: ghcr.io
19+
image: coredns-nomad
20+
version: v1.11.1
21+
platform: ${{ matrix.platform }}
22+
arch: ${{ matrix.arch }}
23+
create-manifest:
24+
needs:
25+
- build-images
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Set tags
29+
id: tags
30+
run: |
31+
echo "manifest=${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}" >> $GITHUB_OUTPUT
32+
echo "tag=${{ env.version }}" >> $GITHUB_OUTPUT
33+
- name: Login
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.registry}}
37+
username: ${{ github.repository_owner }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
- name: Create Manifest
40+
run: |
41+
docker manifest create ${{ steps.tags.outputs.manifest }}:${{ steps.tags.outputs.tag }} \
42+
--amend ${{ steps.tags.outputs.manifest }}-linux-arm64:${{ steps.tags.outputs.tag }} \
43+
--amend ${{ steps.tags.outputs.manifest }}-linux-amd64:${{ steps.tags.outputs.tag }}
44+
docker manifest annotate --arch arm64 ${{ steps.tags.outputs.manifest }}:${{ steps.tags.outputs.tag }} \
45+
${{ steps.tags.outputs.manifest }}-linux-arm64:${{ steps.tags.outputs.tag }}
46+
docker manifest annotate --arch amd64 ${{ steps.tags.outputs.manifest }}:${{ steps.tags.outputs.tag }} \
47+
${{ steps.tags.outputs.manifest }}-linux-amd64:${{ steps.tags.outputs.tag }}
48+
docker manifest push ${{ steps.tags.outputs.manifest }}:${{ steps.tags.outputs.tag }}

0 commit comments

Comments
 (0)