Skip to content

Commit

Permalink
Added github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
djthorpe committed Jan 25, 2024
1 parent 89fde22 commit c1293b1
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build target image
on:
workflow_call:
inputs:
registry:
description: 'Docker Registry'
required: true
type: string
default: 'ghcr.io'
image:
description: 'Image'
required: true
type: string
version:
description: 'Version'
required: true
type: string
platform:
description: 'Platform'
required: true
type: string
arch:
description: 'Architecture'
required: true
type: string
jobs:
build:
name: Build
runs-on: ${{ inputs.platform == 'linux' && (inputs.arch == 'arm64' || inputs.arch == 'arm') && 'self-hosted' || 'ubuntu-latest' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set tags
id: tags
run: |
echo "image=${{ inputs.registry }}/${{ github.repository_owner }}/${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.arch }}" >> $GITHUB_OUTPUT
echo "tag=${{ inputs.version }}" >> $GITHUB_OUTPUT
- name: Login
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: |
docker build \
--tag ${{ steps.tags.outputs.image }}:${{ steps.tags.outputs.tag }} \
--build-arg ARCH=${{ inputs.arch }} \
--build-arg PLATFORM=${{ inputs.platform }} \
--build-arg VERSION=${{ inputs.version }} \
--file etc/docker/Dockerfile .
- name: Push
run: |
docker push ${{ steps.tags.outputs.image }}:${{ steps.tags.outputs.tag }}
48 changes: 48 additions & 0 deletions .github/workflows/make-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Make arm64 and amd64 docker images
on:
workflow_dispatch:

env:
registry: ghcr.io
image: coredns-nomad
version: v1.11.1

jobs:
build-images:
strategy:
matrix:
platform: [ linux ]
arch: [ arm64, amd64 ]
uses: mutablelogic/go-coredns-nomad/.github/workflows/build-image.yaml@main
with:
registry: ghcr.io
image: coredns-nomad
version: v1.11.1
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
create-manifest:
needs:
- build-images
runs-on: ubuntu-latest
steps:
- name: Set tags
id: tags
run: |
echo "manifest=${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}" >> $GITHUB_OUTPUT
echo "tag=${{ env.version }}" >> $GITHUB_OUTPUT
- name: Login
uses: docker/login-action@v3
with:
registry: ${{ env.registry}}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create Manifest
run: |
docker manifest create ${{ steps.tags.outputs.manifest }}:${{ steps.tags.outputs.tag }} \
--amend ${{ steps.tags.outputs.manifest }}-linux-arm64:${{ steps.tags.outputs.tag }} \
--amend ${{ steps.tags.outputs.manifest }}-linux-amd64:${{ steps.tags.outputs.tag }}
docker manifest annotate --arch arm64 ${{ steps.tags.outputs.manifest }}:${{ steps.tags.outputs.tag }} \
${{ steps.tags.outputs.manifest }}-linux-arm64:${{ steps.tags.outputs.tag }}
docker manifest annotate --arch amd64 ${{ steps.tags.outputs.manifest }}:${{ steps.tags.outputs.tag }} \
${{ steps.tags.outputs.manifest }}-linux-amd64:${{ steps.tags.outputs.tag }}
docker manifest push ${{ steps.tags.outputs.manifest }}:${{ steps.tags.outputs.tag }}

0 comments on commit c1293b1

Please sign in to comment.