pdf.js.mirror/.github/workflows/notify-pdf-sync.yml
dependabot[bot] 5b99173043
Bump actions/create-github-app-token from 3.1.1 to 3.2.0
Bumps [actions/create-github-app-token](https://github.com/actions/create-github-app-token) from 3.1.1 to 3.2.0.
- [Release notes](https://github.com/actions/create-github-app-token/releases)
- [Changelog](https://github.com/actions/create-github-app-token/blob/main/CHANGELOG.md)
- [Commits](1b10c78c78...bcd2ba4921)

---
updated-dependencies:
- dependency-name: actions/create-github-app-token
  dependency-version: 3.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-19 23:19:08 +00:00

78 lines
2.3 KiB
YAML

name: Notify PDF sync
on:
push:
branches: [master]
paths:
- "test/pdfs/*.pdf"
- "test/pdfs/*.pdf.link"
permissions:
contents: read
jobs:
notify:
runs-on: ubuntu-latest
environment: sync_pdfs
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
persist-credentials: false
- name: Check for added PDF files
id: check
run: |
git fetch --no-tags --depth=1 origin ${{ github.event.before }}
mapfile -t added < <(
git diff --diff-filter=A --name-only \
${{ github.event.before }} \
${{ github.sha }} \
-- \
':(glob)test/pdfs/*.pdf' \
':(glob)test/pdfs/*.pdf.link'
)
if [ "${#added[@]}" -gt 0 ]; then
echo "has_added=true" >> "$GITHUB_OUTPUT"
printf 'files_json=%s\n' "$(printf '%s\n' "${added[@]}" | jq -Rsc 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
else
echo "has_added=false" >> "$GITHUB_OUTPUT"
echo 'files_json=[]' >> "$GITHUB_OUTPUT"
fi
- name: Generate app token
if: steps.check.outputs.has_added == 'true'
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.CLIENT_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: mozilla
repositories: pdf.js.pdfs
- name: Trigger sync
if: steps.check.outputs.has_added == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
FILES_JSON: ${{ steps.check.outputs.files_json }}
run: |
payload=$(jq -nc \
--arg before "${{ github.event.before }}" \
--arg after "${{ github.sha }}" \
--argjson files "$FILES_JSON" \
'{
event_type: "pdf-added",
client_payload: {
before: $before,
after: $after,
files: $files
}
}')
gh api repos/mozilla/pdf.js.pdfs/dispatches \
--method POST \
--input - <<< "$payload"