Files
dependabot[bot]andAlex 46a5b740d9 chore(deps): bump actions/download-artifact from 8.0.1 to 8.0.2 (#2914)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex <25013571+alexhb1@users.noreply.github.com>
2026-10-16 11:04:16 +01:00

201 lines
6.6 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: false
jobs:
resolve_ref:
name: Resolve Nightly Ref
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
outputs:
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}"
from_ref="$(git describe --tags --abbrev=0 --match 'v*' origin/main)"
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@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
with:
cache-image: false
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- 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@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.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@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: openapi-${{ needs.resolve_ref.outputs.nightly_tag }}
path: backend/build/openapi/grimmory-openapi.json
retention-days: 30
generate-notes:
name: Generate Notes
needs:
- resolve_ref
uses: ./.github/workflows/compute-release-notes.yml
permissions:
contents: read
with:
from-ref: ${{ needs.resolve_ref.outputs.from_ref }}
to-ref: ${{ needs.resolve_ref.outputs.commit_sha }}
secrets: inherit
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:
- 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 }}
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.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 }}