Skip to content

Update Webmentions

Update Webmentions #59

name: Update Webmentions
on:
workflow_dispatch: # Allow running on-demand
schedule:
# Every Monday at 8:00 UTC (4:00 Eastern)
- cron: '0 8 * * 1'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update:
name: Update Webmentions
runs-on: ubuntu-latest
env:
BRANCH_NAME: auto-webmentions
steps:
- uses: actions/checkout@v4
with:
# Use a separate key so the resulting PR also runs GH Actions
# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs
ssh-key: ${{ secrets.DEPLOY_KEY }}
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: yarn
- run: yarn install
- run: yarn webmentions
env:
WEBMENTION_IO_TOKEN: ${{ secrets.WEBMENTION_IO_TOKEN }}
- name: Commit & push changes
run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Automated webmentions update"
git push -f origin ${{ github.ref_name }}:$BRANCH_NAME
- name: Open pull request if needed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR=$(gh pr list --head $BRANCH_NAME --json number -q '.[0].number')
if [ -z $PR ]; then
gh pr create \
--head $BRANCH_NAME \
--title "Automated webmentions update" \
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
else
echo "Pull request already exists, won't create a new one."
fi