Skip to content

Update Downloads #146629

Update Downloads

Update Downloads #146629

# Regenerates the download json
name: Update Downloads
on:
workflow_dispatch:
schedule:
- cron: "*/15 * * * *"
jobs:
update-downloads:
runs-on: ubuntu-latest
permissions:
contents: write # commits the regenerated JSON and syncs it to prerelease
outputs:
changes_detected: ${{ steps.auto-commit.outputs.changes_detected }}
commit: ${{ steps.auto-commit.outputs.commit_hash }}
commit_prerelease: ${{ steps.sync-prerelease.outputs.commit_hash }}
prerelease_version: ${{ steps.get-versions.outputs.prerelease_version }}
steps:
- name: Checkout Repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: true # git-auto-commit-action and the push to prerelease use these
# token: ${{ secrets.COMMIT_PAT }}
- name: Regenerate Download Json
uses: ./.github/workflows/actions/release-info
with:
owner: 'quarto-dev'
repo: 'quarto-cli'
out-path: 'docs/download/'
redirects-path: '_redirects'
redirects-template: /download/latest/$$prefix$$-$$suffix$$.$$extension$$
pre-redirects-template: /download/prerelease/$$prefix$$-$$suffix$$.$$extension$$
github-token: ${{ github.token }}
- name: Get versions from generated JSON
id: get-versions
run: |
prerelease_version=$(jq -r '.version' docs/download/_prerelease.json)
echo "prerelease_version=$prerelease_version" >> "$GITHUB_OUTPUT"
echo "Prerelease version: $prerelease_version"
- name: Commit Changes to main branch
id: auto-commit
uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
with:
repository: .
commit_user_name: Github Action Runner
commit_user_email: runner@quarto.org
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- name: Sync generated downloads to prerelease branch
id: sync-prerelease
if: ${{ steps.auto-commit.outputs.changes_detected == 'true' }}
env:
MAIN_SHA: ${{ steps.auto-commit.outputs.commit_hash }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git checkout prerelease
# _redirects is authoritative on main (manual redirects reach prerelease
# via the backport workflow), so overwrite the generated files outright
# instead of cherry-picking — never conflicts.
git checkout "$MAIN_SHA" -- _redirects docs/download/_download.json docs/download/_prerelease.json
if git diff --cached --quiet; then
echo "No changes to sync to prerelease"
else
git commit -m "Sync generated download redirects from main"
git push origin prerelease
fi
echo "commit_hash=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
# If a new commit has been made with updated downloads,
# then publish the changes using the new commit as ref to checkout
# in the reusable publish workflow
publish-changes-release:
needs: [ update-downloads ]
if: ${{ needs.update-downloads.outputs.changes_detected == 'true' }}
uses: ./.github/workflows/publish.yml
# A called workflow cannot exceed its caller's grant.
permissions:
contents: read
statuses: write
with:
ref: ${{ needs.update-downloads.outputs.commit }}
prerelease: false
secrets:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# If a new commit has been made with updated downloads,
# then publish the changes using the new commit as ref to checkout
# in the reusable publish workflow
publish-changes-prerelease:
needs: [ update-downloads ]
if: ${{ needs.update-downloads.outputs.changes_detected == 'true' }}
uses: ./.github/workflows/publish.yml
# A called workflow cannot exceed its caller's grant.
permissions:
contents: read
statuses: write
with:
ref: ${{ needs.update-downloads.outputs.commit_prerelease }}
prerelease: true
secrets:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# If a new commit has been made with updated downloads,
# trigger the reference page update workflow
update-prerelease-reference:
needs: [ update-downloads ]
if: ${{ needs.update-downloads.outputs.changes_detected == 'true' }}
uses: ./.github/workflows/update-prerelease-reference.yml
# A called workflow cannot exceed its caller's grant.
permissions:
contents: write
pull-requests: write
with:
version: ${{ needs.update-downloads.outputs.prerelease_version }}
secrets:
ISSUE_COMMENT_TRIGGER_PAT: ${{ secrets.ISSUE_COMMENT_TRIGGER_PAT }}