Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Docker Nightly Builds #209

Docker Nightly Builds

Docker Nightly Builds #209

name: Docker Nightly Builds
on:
schedule:
# 03.15 AM UTC
- cron: '15 3 * * *'
jobs:
docker-image-build:
environment: 'dockerhub'
env:
DOCKER_IMAGE_NAME: bojanraic/bwsm-eso
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PAT: ${{ secrets.DOCKERHUB_PAT }}
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v4
- name: Dockerhub Login
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_PAT }}
- name: QEMU Setup
uses: docker/setup-qemu-action@v3
- name: Docker Buildx Setup
uses: docker/setup-buildx-action@v3
- name: Build Nightly amd64 image
uses: docker/build-push-action@v6
with:
context: src
push: true
provenance: false
platforms: linux/amd64
build-args: |
BWS_DL_ARCH=x86_64
tags: ${{ env.DOCKER_IMAGE_NAME }}:nightly-amd64
- name: Build Nightly arm64 image
uses: docker/build-push-action@v6
with:
context: src
push: true
provenance: false
platforms: linux/arm64
build-args: |
BWS_DL_ARCH=aarch64
tags: ${{ env.DOCKER_IMAGE_NAME }}:nightly-arm64
- name: Push Multiplatform Nightly Image Manifest
uses: Noelware/docker-manifest-action@master
with:
inputs: ${{ env.DOCKER_IMAGE_NAME }}:nightly
images: ${{ env.DOCKER_IMAGE_NAME }}:nightly-amd64,${{ env.DOCKER_IMAGE_NAME }}:nightly-arm64
push: true
- name: Most Recent Semver Tag
uses: actions-ecosystem/action-get-latest-tag@v1
with:
semver_only: true
id: most-recent-tag
- name: Switch to Most Recent Tag
if: steps.most-recent-tag.outputs.tag
run: git checkout ${{ steps.most-recent-tag.outputs.tag }}
- name: Build Tagged amd64 image
uses: docker/build-push-action@v6
with:
context: src
push: true
provenance: false
platforms: linux/amd64
build-args: |
BWS_DL_ARCH=x86_64
tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.most-recent-tag.outputs.tag }}-amd64, ${{ env.DOCKER_IMAGE_NAME }}:latest-amd64
- name: Build Tagged arm64 image
uses: docker/build-push-action@v6
with:
context: src
push: true
provenance: false
platforms: linux/arm64
build-args: |
BWS_DL_ARCH=aarch64
tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.most-recent-tag.outputs.tag }}-arm64, ${{ env.DOCKER_IMAGE_NAME }}:latest-arm64
- name: Push Multiplatform Tagged Image Manifest
uses: Noelware/docker-manifest-action@master
with:
inputs: ${{ env.DOCKER_IMAGE_NAME }}:latest, ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.most-recent-tag.outputs.tag }}
images: ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.most-recent-tag.outputs.tag }}-amd64, ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.most-recent-tag.outputs.tag }}-arm64
push: true
- name: Cleanup Internediate Images
run: |
REPO=${{ env.DOCKER_IMAGE_NAME }}
DH_USER=${{ env.DOCKERHUB_USERNAME }}
DH_PASS=${{ env.DOCKERHUB_PAT }}
JWT=$(curl -s -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d "{\"username\":\"${DH_USER}\",\"password\":\"${DH_PASS}\"}" -L 'https://hub.docker.com/v2/users/login' | jq -r '.token')
tags=$(curl -s -L "https://hub.docker.com/v2/repositories/${REPO}/tags?page_size=1024" | jq -r ".results[].name" | grep -E "\-arm64|\-amd64")
# Iterate over tags
for tag in $tags; do
echo "Deleting intermediate tag: $tag"
curl -s "https://hub.docker.com/v2/repositories/${REPO}/tags/${tag}" -X DELETE -H "Authorization: JWT ${JWT}"
done