Skip to content

Add Oct 6, 2025 update #22

Add Oct 6, 2025 update

Add Oct 6, 2025 update #22

Workflow file for this run

name: Continuous Integration Workflow
on:
# Trigger the workflow on push for the "main" branch
push:
branches: ["main"]
# Allow this workflow to be ran manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
update-and-purge:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Check out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Required for github.event.before
with:
fetch-depth: 2
- name: Extract changed files
id: changes
run: |
# Get all changed files across the entire push
all_changed=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
# Extract news years
news_files=$(echo "$all_changed" | grep -E "^news-[0-9]{4}\.md$" | sed 's/news-//; s/\.md//' | sort -u | tr '\n' ' ' | sed 's/ $//')
# Check for other files
has_sponsors=$(echo "$all_changed" | grep -q "^sponsors\.json$" && echo "true" || echo "false")
has_support=$(echo "$all_changed" | grep -q "^support-links\.md$" && echo "true" || echo "false")
current_year=$(date +%Y)
echo "years=${news_files:-$current_year}" >> $GITHUB_OUTPUT
echo "has_news=${news_files:+true}" >> $GITHUB_OUTPUT
echo "has_sponsors=$has_sponsors" >> $GITHUB_OUTPUT
echo "has_support=$has_support" >> $GITHUB_OUTPUT
- name: Trigger autofill-site update
if: steps.changes.outputs.has_news == 'true'
# NOTE: Classic PAT token is recommended since we can set it to never expire. Fine-grained
# tokens have a maximum lifetime of 1 year. If switching to fine-grained tokens in the
# future, these Repository permissions are required:
#
# - Actions: Read and write
# - Contents: Read and write
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.WEBSITE_DISPATCH_TOKEN }}" \
https://api.github.com/repos/tohodo/autofill-site/dispatches \
-d '{
"event_type": "news-updated",
"client_payload": {
"changed_files": "${{ steps.changes.outputs.years }}",
"delay_minutes": "1"
}
}'
- name: Purge CDN cache
# Run a set of commands using the runners shell
if: steps.changes.outputs.has_news == 'true' || steps.changes.outputs.has_sponsors == 'true' || steps.changes.outputs.has_support == 'true'
run: |
# Build dynamic paths array
paths=""
# Add news files
for year in ${{ steps.changes.outputs.years }}; do
if [ -n "$paths" ]; then paths="$paths,"; fi
paths="$paths\"/gh/tohodo/autofill@main/news-${year}.md\""
done
# Add sponsors.json if changed
if [ "${{ steps.changes.outputs.has_sponsors }}" = "true" ]; then
if [ -n "$paths" ]; then paths="$paths,"; fi
paths="$paths\"/gh/tohodo/autofill@main/sponsors.json\""
fi
# Add support-links.md if changed
if [ "${{ steps.changes.outputs.has_support }}" = "true" ]; then
if [ -n "$paths" ]; then paths="$paths,"; fi
paths="$paths\"/gh/tohodo/autofill@main/support-links.md\""
fi
# Only purge if we have paths to purge
if [ -n "$paths" ]; then
curl -X POST \
https://purge.jsdelivr.net/ \
-H 'content-type: application/json' \
-d "{\"path\": [$paths]}"
fi