Schedule Snapshot #213
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: Schedule Snapshot | |
on: | |
schedule: | |
# Runs against the default branch every day overnight | |
- cron: "18 3 * * *" | |
workflow_dispatch: | |
inputs: | |
dryRun: | |
description: "Dry-Run" | |
default: false | |
required: false | |
type: boolean | |
env: | |
DEFAULT_BRANCH: dev | |
jobs: | |
changes-since-last-snapshot: | |
name: Detect changes since last snapshot | |
runs-on: ubuntu-latest | |
outputs: | |
has-changes: ${{ steps.gitsha.outputs.latestsha }} != ${{ steps.current-registry-sha.outputs.registrysha }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.DEFAULT_BRANCH }} | |
- name: Get Git SHA | |
id: gitsha | |
run: echo "latestsha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Generate Token | |
uses: actions/create-github-app-token@v1 | |
id: generate-token | |
with: | |
app-id: "${{ secrets.APP_ID }}" | |
private-key: "${{ secrets.APP_PRIVATE_KEY }}" | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ steps.generate-token.outputs.token }} | |
- name: Pull info from registry | |
id: current-registry-sha | |
run: | | |
docker pull ghcr.io/${{ github.repository }}:${{ env.DEFAULT_BRANCH }} | |
echo registrysha=$(docker inspect -f '{{ index .Config.Labels "org.opencontainers.image.revision" }}' ghcr.io/${{ github.repository }}:${{ env.DEFAULT_BRANCH }}) >> $GITHUB_OUTPUT | |
- name: Summarize Job | |
run: | | |
echo "## Detect Commits" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "Is Dry Run? ${{ inputs.dryRun }}" >> $GITHUB_STEP_SUMMARY | |
echo "${{steps.gitsha.outputs.latestsha}} - Latest Repository SHA on branch ${{ env.DEFAULT_BRANCH }}" >> $GITHUB_STEP_SUMMARY | |
echo "${{ steps.current-registry-sha.outputs.registrysha }} - Latest SHA on Registry Image ghcr.io/${{ github.repository }}:${{ env.DEFAULT_BRANCH }}" >> $GITHUB_STEP_SUMMARY | |
run-publish-snapshot: | |
needs: | |
- changes-since-last-snapshot | |
if: needs.changes-since-last-snapshot.outputs.has-changes && !inputs.dryRun | |
uses: ./.github/workflows/publish-snapshot.yaml | |
secrets: inherit |