xmonad-web: Update sponsors #444
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: 'xmonad-web: Update sponsors' | |
on: | |
workflow_dispatch: | |
schedule: | |
# Run every day | |
- cron: '0 2 * * *' | |
jobs: | |
refresh: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone project | |
uses: actions/checkout@v4 | |
with: | |
repository: xmonad/xmonad-web | |
token: ${{ secrets.ADMIN_GITHUB_TOKEN }} | |
- name: Refresh sponsors | |
run: | | |
set -ex | |
# check that we're running the code we expect to be running | |
sha256sum --check <<<"29a68afb0438198226ce3cf1cda098ad51ab3a5b36c408f5e416afedc892d2b0 _sponsors.sh" | |
sha256sum --check <<<"c7d700a800a637714830b276abb1fb4d2cbada200a7ab9c1918d8ed97855c698 Makefile" | |
make -B -f Makefile _data/sponsors-named.json | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ADMIN_GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }} | |
- name: If changed, commit, push, create (or update) PR | |
run: | | |
set -ex | |
git config user.name 'github-actions[bot]' | |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
# exit if no changes against the default branch | |
git diff --quiet --exit-code && exit | |
# exit if there's already a sponsors-update branch with the same sponsors data | |
if git fetch origin sponsors-update; then | |
git diff --quiet --exit-code FETCH_HEAD -- _data/sponsors-named.json && exit | |
fi | |
git checkout -b sponsors-update | |
git commit -a -m 'data: Update sponsors' | |
git push -f -u origin sponsors-update:sponsors-update | |
# open pull request if there isn't one already | |
err=$( | |
GITHUB_TOKEN="${ADMIN_GITHUB_TOKEN:?}" gh pr create \ | |
--title='data: Update sponsors' \ | |
--body='(automatic PR by https://github.com/liskin/xmonad-maintenance)' \ | |
2>&1 | |
) && ret=$? || ret=$? | |
if (( ret )) && [[ "$err" != *"a pull request for branch"*"already exists:"* ]]; then | |
exit $? | |
else | |
printf '%s\n' "$err" >> $GITHUB_STEP_SUMMARY | |
fi | |
env: | |
ADMIN_GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }} | |
workflow-keepalive: | |
if: github.event_name == 'schedule' | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
steps: | |
- uses: liskin/gh-workflow-keepalive@v1 |