Files
grimmory/.github/workflows/publish-nightly.yml
T
dependabot[bot] ea80fc0356 chore(deps): bump docker/login-action from 4.4.0 to 4.6.0 (#2444)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-08-23 10:18:29 +01:00

234 lines
8.4 KiB
YAML

name: Nightly - Build and Publish
on:
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
inputs:
post_discord:
description: 'Post the Discord nightly announcement'
required: false
type: boolean
default: true
jobs:
resolve_ref:
name: Resolve Nightly Ref
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
outputs:
base_tag: ${{ steps.resolve.outputs.base_tag }}
commit_sha: ${{ steps.resolve.outputs.commit_sha }}
from_ref: ${{ steps.resolve.outputs.from_ref }}
nightly_tag: ${{ steps.resolve.outputs.nightly_tag }}
steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Record Resolved Commit
id: resolve
env:
GH_TOKEN: ${{ github.token }}
run: |
set -eu
git fetch origin main --tags --force
short_sha="$(git rev-parse --short HEAD)"
build_date="$(date -u +%Y%m%d)"
nightly_tag="nightly-${build_date}-${short_sha}"
base_tag="$(git describe --tags --abbrev=0 --match 'v*' origin/main)"
from_ref="$base_tag"
echo "base_tag=${base_tag}" >> "$GITHUB_OUTPUT"
echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
echo "from_ref=${from_ref}" >> "$GITHUB_OUTPUT"
echo "nightly_tag=${nightly_tag}" >> "$GITHUB_OUTPUT"
build-and-push:
name: Build and Push Nightly Image
needs: [resolve_ref, test-suite]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image_tag: ${{ steps.record.outputs.image_tag }}
steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 1
ref: ${{ needs.resolve_ref.outputs.commit_sha }}
- name: Record Nightly Build Metadata
id: record
env:
NIGHTLY_TAG: ${{ needs.resolve_ref.outputs.nightly_tag }}
run: |
echo "image_tag=${NIGHTLY_TAG}" >> "$GITHUB_OUTPUT"
echo "nightly_tag=${NIGHTLY_TAG}" >> "$GITHUB_ENV"
echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
echo "Nightly tag: ${NIGHTLY_TAG}"
- name: Set Up QEMU for Multi-Arch Builds
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
with:
cache-image: false
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Authenticate to Docker Hub
if: ${{ vars.DOCKERHUB_REGISTRY != '' }}
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Authenticate to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Docker meta
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: |
${{ vars.DOCKERHUB_REGISTRY }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=nightly
type=raw,value=${{ env.nightly_tag }}
- name: Build and push Stable image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
build-args: |
APP_VERSION=${{ env.nightly_tag }}
APP_REVISION=${{ env.commit_sha }}
cache-from: |
type=gha,scope=image-shared
type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
cache-to: |
type=gha,scope=image-shared,mode=max
type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max
export-openapi:
name: Export Nightly OpenAPI Artifact
needs: [resolve_ref]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout Workflow Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 1
ref: ${{ needs.resolve_ref.outputs.commit_sha }}
- name: Export OpenAPI JSON
uses: ./.github/actions/export-openapi
with:
checkout_ref: ${{ needs.resolve_ref.outputs.commit_sha }}
app_version: ${{ needs.resolve_ref.outputs.nightly_tag }}
- name: Upload Nightly OpenAPI Artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: openapi-${{ needs.resolve_ref.outputs.nightly_tag }}
path: backend/build/openapi/grimmory-openapi.json
retention-days: 30
generate-notes:
name: Nightly Changelog
if: ${{ always() && needs.test-suite.result == 'success' }}
needs: [resolve_ref, test-suite]
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
compare_url: ${{ steps.notes.outputs.compare_url }}
details_url: ${{ steps.notes.outputs.details_url }}
predicted_version: ${{ steps.notes.outputs.predicted_version }}
release_notes: ${{ steps.notes.outputs.release_notes }}
release_type: ${{ steps.notes.outputs.release_type }}
released: ${{ steps.notes.outputs.released }}
to_sha: ${{ steps.notes.outputs.to_sha }}
available: ${{ steps.webhook_secrets_check.outputs.available }}
steps:
- name: Check Discord Webhook secrets
id: webhook_secrets_check
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_NIGHTLY_WEBHOOK != '' && secrets.DISCORD_NIGHTLY_WEBHOOK || secrets.DISCORD_RELEASE_WEBHOOK }}
run: |
# Check here rather than in the `if`.
# Github actions does not support the `secrets` context in `if` blocks.
if [[ -n "${DISCORD_WEBHOOK}" ]]; then
echo "available=true" >> $GITHUB_OUTPUT
else
echo "available=false" >> $GITHUB_OUTPUT
fi
- name: Checkout Workflow Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 1
- name: Build Full Changelog
if: ${{ steps.webhook_secrets_check.outputs.available == 'true' }}
id: notes
uses: ./.github/actions/compute-release-notes
with:
base_tag: ${{ needs.resolve_ref.outputs.base_tag }}
from_ref: ${{ needs.resolve_ref.outputs.from_ref }}
repository_url: ${{ format('{0}/{1}', github.server_url, github.repository) }}
to_ref: ${{ needs.resolve_ref.outputs.commit_sha }}
notify-discord:
name: Notify Discord (Nightly)
if: ${{ always() && (github.event_name == 'schedule' || inputs.post_discord) && needs.generate-notes.result == 'success' && needs.build-and-push.result == 'success' && needs.export-openapi.result == 'success' && needs.generate-notes.outputs.available == 'true' && needs.generate-notes.outputs.predicted_version != '' }}
needs: [resolve_ref, build-and-push, export-openapi, generate-notes]
permissions: {}
uses: ./.github/workflows/notify-discord-release-notes.yml
secrets:
discord_webhook: ${{ secrets.DISCORD_NIGHTLY_WEBHOOK != '' && secrets.DISCORD_NIGHTLY_WEBHOOK || secrets.DISCORD_RELEASE_WEBHOOK }}
with:
channel: nightly
candidate_sha: ${{ needs.resolve_ref.outputs.commit_sha }}
base_tag: ${{ needs.resolve_ref.outputs.base_tag }}
current_version: ${{ needs.resolve_ref.outputs.nightly_tag }}
details_url: ${{ needs.generate-notes.outputs.details_url }}
compare_url: ${{ needs.generate-notes.outputs.compare_url }}
mention_text: ${{ vars.DISCORD_NIGHTLY_MENTIONS }}
predicted_version: ${{ needs.generate-notes.outputs.predicted_version }}
test-suite:
name: Test Suite
needs: [resolve_ref]
uses: ./.github/workflows/test-suite.yml
permissions:
contents: read
checks: write
with:
checkout_ref: ${{ needs.resolve_ref.outputs.commit_sha }}