Skip to content

Commit

Permalink
Configure github action to build images
Browse files Browse the repository at this point in the history
  • Loading branch information
HadrienPatte committed Apr 1, 2024
1 parent ca34eaa commit 0637393
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/scripts/build-all-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

for image in $(ls images); do
echo "Building $image"
./.github/scripts/build-image.sh $image
done
22 changes: 22 additions & 0 deletions .github/scripts/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail

IMAGE=$1
VERSION=$(./images/${IMAGE}/version.sh)

if [[ -z $VERSION ]]; then
echo "Failed to retrieve latest version for $IMAGE"
else
docker buildx build \
--push \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/hadrienpatte/${IMAGE}:${VERSION} \
--tag ghcr.io/hadrienpatte/${IMAGE}:latest \
--build-arg VERSION=${VERSION} \
--label "org.opencontainers.image.authors=HadrienPatte" \
--label "org.opencontainers.image.source=https://github.com/HadrienPatte/images" \
--label "org.opencontainers.image.version=${VERSION}" \
--label "org.opencontainers.image.vendor=HadrienPatte" \
--label "org.opencontainers.image.title=${IMAGE}" \
- < images/${IMAGE}/Dockerfile
fi
24 changes: 24 additions & 0 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
on:
push:
schedule:
- cron: "0 0 * * *"

jobs:
build-images:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run build script
run: ./.github/scripts/build-all-images.sh

0 comments on commit 0637393

Please sign in to comment.