2022-09-15 19:41:35 -04:00
|
|
|
name: Open a PR to remove broken links on a schedule
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
schedule:
|
|
|
|
- cron: '0 0 * * *'
|
|
|
|
|
2022-09-16 15:39:16 -04:00
|
|
|
permissions:
|
|
|
|
issues: write
|
|
|
|
pull-requests: write
|
|
|
|
|
2022-09-15 19:41:35 -04:00
|
|
|
jobs:
|
|
|
|
check-for-broken-links:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
pull-requests: write
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
2022-09-16 15:39:16 -04:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.REMOVE_BROKEN_LINKS_GH_TOKEN }}
|
2022-09-15 19:41:35 -04:00
|
|
|
|
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 13
|
|
|
|
|
|
|
|
- uses: ipfs/aegir/actions/cache-node-modules@master
|
|
|
|
with:
|
|
|
|
directories: |
|
|
|
|
README.md
|
|
|
|
build: |
|
|
|
|
npm run build:readme
|
|
|
|
cache_name: readme
|
|
|
|
|
|
|
|
- name: Set up Ruby 3.1.2
|
|
|
|
uses: ruby/setup-ruby@v1
|
|
|
|
with:
|
|
|
|
ruby-version: 3.1.2
|
|
|
|
|
2022-09-16 15:39:16 -04:00
|
|
|
# Cache the files created by awesome_bot
|
|
|
|
- name: Cache awesome_bot files
|
|
|
|
uses: actions/cache@v3
|
|
|
|
id: awesome_bot_cache
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
ab-results-README.md-filtered.json
|
|
|
|
ab-results-README.md-markdown-table.json
|
|
|
|
ab-results-README.md.json
|
|
|
|
key: ${{ runner.os }}-awesome_bot-${{ hashFiles('README.md') }}
|
|
|
|
|
2022-09-15 19:41:35 -04:00
|
|
|
- name: Install and run awesome_bot
|
2022-09-16 15:39:16 -04:00
|
|
|
if: steps.awesome_bot_cache.outputs.cache-hit != 'true'
|
2022-09-15 19:41:35 -04:00
|
|
|
run: |
|
|
|
|
gem install awesome_bot
|
|
|
|
awesome_bot --allow 429 --allow-redirect --allow-dupe --allow-ssl -w ipfs.io README.md || echo
|
|
|
|
|
|
|
|
- name: Remove broken links
|
2022-09-16 12:28:26 -04:00
|
|
|
id: remove-broken-links
|
2022-09-15 19:41:35 -04:00
|
|
|
run: |
|
|
|
|
node scripts/remove-broken-links.js
|
2022-09-16 12:28:26 -04:00
|
|
|
echo "Changed files:"
|
|
|
|
git ls-files -m
|
|
|
|
changed_data_files_count=$(git ls-files -m data | wc -l | tr -d ' ')
|
|
|
|
echo "changed_data_files_count='$changed_data_files_count'"
|
2023-02-08 04:45:37 -05:00
|
|
|
echo "changed_data_files_count=$changed_data_files_count" >> $GITHUB_OUTPUT
|
2022-09-15 19:41:35 -04:00
|
|
|
|
2022-09-16 15:39:16 -04:00
|
|
|
- uses: EndBug/add-and-commit@d4d066316a2a85974a05efb42be78f897793c6d9 # v9.1.0 - https://github.com/EndBug/add-and-commit/commit/d4d066316a2a85974a05efb42be78f897793c6d9
|
|
|
|
if: steps.remove-broken-links.outputs.changed_data_files_count != 0
|
2022-09-15 19:41:35 -04:00
|
|
|
with:
|
2022-09-16 15:39:16 -04:00
|
|
|
add: 'data'
|
|
|
|
new_branch: remove-broken-links
|
|
|
|
message: 'chore: Remove broken links'
|
|
|
|
push: 'origin remove-broken-links --set-upstream --force'
|
|
|
|
author_name: 'ipfs-gui-bot'
|
|
|
|
author_email: '108953096+ipfs-gui-bot@users.noreply.github.com'
|
2022-09-15 19:41:35 -04:00
|
|
|
|
|
|
|
- name: pull-request
|
2022-09-16 15:39:16 -04:00
|
|
|
if: steps.remove-broken-links.outputs.changed_data_files_count != 0
|
2022-09-15 19:41:35 -04:00
|
|
|
uses: repo-sync/pull-request@65785d95a5a466e46a9d0708933a3bd51bbf9dde
|
|
|
|
with:
|
2022-09-16 15:39:16 -04:00
|
|
|
source_branch: "remove-broken-links"
|
2022-09-15 19:41:35 -04:00
|
|
|
destination_branch: "master"
|
|
|
|
pr_title: "chore: Remove broken links"
|
|
|
|
pr_body: "Automated PR created by .github/workflows/broken_link_cron.yml"
|
|
|
|
pr_label: "kind/maintenance"
|
|
|
|
pr_draft: false
|
|
|
|
pr_allow_empty: false
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|