Skip to content

Build and push CumulusMX to Docker Hub and ghcr.io #28

Build and push CumulusMX to Docker Hub and ghcr.io

Build and push CumulusMX to Docker Hub and ghcr.io #28

name: Build and push to Docker Hub and ghcr.io
# This workflow is triggered by an update to the upstream-releases file (which is triggered by the check-releases workflow).
# When triggered the latest version of the container is built and pushed to docker hub
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
# Automatically trigger when upstream release file is changed
push:
paths:
- 'upstream-releases/*'
# Allow manual trigger
workflow_dispatch:
# Trigger monthly to ensure images aren't too stale
schedule:
- cron: '51 19 1 * *'
jobs:
build_and_push:
name: Build and push CumulusMX Docker image to Docker Hub and ghcr.io
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Get latest version number
run: |
VER=$(curl -s https://raw.githubusercontent.com/hucknz/cumulusmx/master/upstream-releases/cumulusmx-latest.txt)
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the ghcr.io
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: |
hucknz/cumulusmx
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ env.VERSION }}
type=raw,value=latest
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Notify outcome to Discord
uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
- name: Notify outcome to Slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,workflow,eventName,took,message,commit,job,took
if: always()