nightly and on.push docker builds #161
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: nightly and on.push docker builds | |
on: | |
# to trigger manually if we really need it | |
workflow_dispatch: | |
inputs: | |
tag_name: | |
description: "the name of the tag for the docker image" | |
type: "string" | |
required: true | |
# to trigger | |
push: | |
tags: | |
- "*.*.*" | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
# triggers every day at 00:00 UTC (midnight) | |
- cron: '0 0 * * *' | |
jobs: | |
docker-amd64: | |
environment: 'docker' | |
runs-on: ubuntu-latest | |
steps: | |
- 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 Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# push with new tag if this is a trigged by a git tag | |
- name: Docker Build and Push | |
if: ${{ github.event == 'workflow_dispatch' }} | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
context: . | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
tags: | | |
jessebot/matrix-alertmanager-bot:${{ inputs.tag_name }} | |
# push with ref_name if this is NOT scheduled or manually run | |
- name: Docker Build and Push | |
if: ${{ github.event != 'workflow_dispatch' && github.event != 'schedule' }} | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
context: . | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
tags: | | |
jessebot/matrix-alertmanager-bot:${{ github.ref_name }} | |
- name: Get most recent tag | |
if: ${{ github.event == 'schedule' }} | |
run: echo "last_tag=$(git describe --tags --abbrev=0) >> $GITHUB_ENV | |
# push with last known tag and nightly if this is a scheduled run | |
- name: Docker Build and Push | |
if: ${{ github.event == 'schedule' }} | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
context: . | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
tags: | | |
jessebot/matrix-alertmanager-bot:nightly | |
jessebot/matrix-alertmanager-bot:${{ env.last_tag }} |