Skip to content

Nightly Release

Nightly Release #1

name: Nightly Release
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: {}
jobs:
check-date:
name: Check dates
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.code-change.outputs.should-run }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check if code has changed with 24 hours
continue-on-error: true
id: code-change
run: |
[[ $(git rev-list --after="24 hours" --first-parent HEAD) ]] && echo "should-run=true" >> GITHUB_OUTPUT
build-release:
name: Build and release Docker image
runs-on: ubuntu-latest
needs: check-date
permissions:
contents: read
packages: write
attestations: write
id-token: write
if: needs.check-date.outputs.should-run == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} # Use the GitHub token for authentication
- name: Build Docker image
run: |
docker build \
-t "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}" \
-t "ghcr.io/${GITHUB_REPOSITORY}:nightly" .
- name: Release Docker image
run: |
docker push "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}"
docker push "ghcr.io/${GITHUB_REPOSITORY}:nightly"