From dd28c19ba7ec51e3c410a87aef366b378de4d6b3 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Fri, 16 Sep 2022 09:28:26 -0700 Subject: [PATCH] fix: broken-links workflow (#433) * fix: broken-links workflow * fix: trim bash var * fix: string comparison * fix: github action if condition syntax * debugging * debugging: gh action showing 1 changed file.. what is it? * fix: only count changed data files for scheduled broken link PRs --- .github/workflows/broken_link_cron.yml | 8 ++++++++ scripts/remove-broken-links.js | 2 ++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/broken_link_cron.yml b/.github/workflows/broken_link_cron.yml index 84fea64..1ab627b 100644 --- a/.github/workflows/broken_link_cron.yml +++ b/.github/workflows/broken_link_cron.yml @@ -38,10 +38,17 @@ jobs: 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 "::set-output name=changed_files::$changed_data_files_count" - uses: stefanzweifel/git-auto-commit-action@49620cd3ed21ee620a48530e81dba0d139c9cb80 + if: steps.remove-broken-links.outputs.changed_data_files_count > 0 with: # Optional. Commit message for the created commit. # Defaults to "Apply automatic changes" @@ -70,6 +77,7 @@ jobs: create_branch: true - 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-${{ github.run_id }}" diff --git a/scripts/remove-broken-links.js b/scripts/remove-broken-links.js index 212ff8b..1be90c0 100644 --- a/scripts/remove-broken-links.js +++ b/scripts/remove-broken-links.js @@ -25,4 +25,6 @@ if (markdownTable.error) { await fs.writeFile(filePath, fileContents, 'utf8') } })() +} else { + console.log('No errors reported by awesome_bot.') }