-
-
Notifications
You must be signed in to change notification settings - Fork 3
52 lines (49 loc) · 1.73 KB
/
update-webmentions.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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@v4
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