Skip to content

Fetch Latest Release #1266

Fetch Latest Release

Fetch Latest Release #1266

name: Fetch Latest Release
on:
schedule:
- cron: "38 * * * *"
workflow_dispatch:
permissions:
contents: write
actions: write
defaults:
run:
shell: bash
jobs:
fetch:
if: github.repository == 'andreasgriffin/andreasgriffin.github.io' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Import APT signing key
env:
APT_GPG_PRIVATE_KEY_ASC: ${{ secrets.APT_GPG_PRIVATE_KEY_ASC }}
run: |
if [[ -n "${APT_GPG_PRIVATE_KEY_ASC:-}" ]]; then
printf '%s' "$APT_GPG_PRIVATE_KEY_ASC" > /tmp/apt-signing-key.asc
gpg --batch --import /tmp/apt-signing-key.asc
else
echo "APT_GPG_PRIVATE_KEY_ASC is not set; continuing without APT repo signing key."
fi
- name: Run fetch_release.sh
id: fetch
env:
APT_GPG_KEY_ID: ${{ secrets.APT_GPG_KEY_ID }}
run: |
set +e
bash ./fetch_release.sh
status=$?
echo "status=$status" >> "$GITHUB_OUTPUT"
if [[ "$status" -eq 1 ]]; then
exit 1
fi
exit 0
- name: Expand untracked files for commit action
if: steps.fetch.outputs.status == '0'
run: git config --local status.showUntrackedFiles all
- name: Commit changes if any
uses: planetscale/ghcommit-action@v0.2.20
if: steps.fetch.outputs.status == '0'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit_message: "Update latest release data"
repo: ${{ github.repository }}
branch: main
file_pattern: "data/latest_release.json content/features/readme/index.md"
- name: Trigger Hugo workflow
if: steps.fetch.outputs.status == '0'
uses: actions/github-script@v7
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "hugo.yaml",
ref: "main"
});