Open a PR to remove broken links on a schedule #19
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: Open a PR to remove broken links on a schedule | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' | |
permissions: | |
issues: write | |
pull-requests: write | |
jobs: | |
check-for-broken-links: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.REMOVE_BROKEN_LINKS_GH_TOKEN }} | |
- 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 | |
# 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') }} | |
- name: Install and run awesome_bot | |
if: steps.awesome_bot_cache.outputs.cache-hit != 'true' | |
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 | |
id: remove-broken-links | |
run: | | |
node scripts/remove-broken-links.js | |
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'" | |
echo "changed_data_files_count=$changed_data_files_count" >> $GITHUB_OUTPUT | |
- 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 | |
with: | |
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' | |
- name: pull-request | |
if: steps.remove-broken-links.outputs.changed_data_files_count != 0 | |
uses: repo-sync/pull-request@65785d95a5a466e46a9d0708933a3bd51bbf9dde | |
with: | |
source_branch: "remove-broken-links" | |
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 }} |