diff --git a/.github/scripts/build-all-images.sh b/.github/scripts/build-all-images.sh new file mode 100755 index 0000000..8a8c0b7 --- /dev/null +++ b/.github/scripts/build-all-images.sh @@ -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 diff --git a/.github/scripts/build-image.sh b/.github/scripts/build-image.sh new file mode 100755 index 0000000..a450185 --- /dev/null +++ b/.github/scripts/build-image.sh @@ -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 diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml new file mode 100644 index 0000000..5a79d30 --- /dev/null +++ b/.github/workflows/build-images.yaml @@ -0,0 +1,31 @@ +--- +on: + push: + #branches: + # - "new-images" + +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: Build and push + # uses: docker/build-push-action@v5 + # with: + # context: . + # platforms: linux/amd64,linux/arm64 + # push: true + # tags: user/app:latest + - name: Run build script + run: ./.github/scripts/build-all-images.sh diff --git a/images/radarr/version.sh b/images/radarr/version.sh index 8b7e039..35914f3 100755 --- a/images/radarr/version.sh +++ b/images/radarr/version.sh @@ -1,3 +1,5 @@ #!/usr/bin/env bash -VERSION=$(curl -s "https://radarr.servarr.com/v1/update/master/changes?os=linux&runtime=netcore" | jq --raw-output '.[0].version') +set -euo pipefail + +VERSION=$(curl -s "https://radarr.servarr.com/v1/update/master/changes?os=linux&runtime=netcore" | jq -r '.[0].version') echo ${VERSION}