Periodic URL Check #11
This file contains hidden or 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: Periodic URL Check | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 0 1 * *' | |
| jobs: | |
| set-up: | |
| name: Load user automation choices | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| # Use the yaml-env-action action. | |
| - name: Load environment from YAML | |
| uses: doughepi/[email protected] | |
| with: | |
| files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence. | |
| outputs: | |
| toggle_url_check_periodically: "${{ env.URL_CHECK_PERIODICALLY }}" | |
| url_error_min: "${{ env.URL_ERROR_MIN }}" | |
| url-check: | |
| name: Check URLs | |
| needs: set-up | |
| if: ${{needs.set-up.outputs.toggle_url_check_periodically == 'true'}} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| status: ${{ steps.check_results.outcome }} | |
| steps: | |
| - name: Run the check | |
| uses: ottrproject/ottr-reports@main | |
| id: check_results | |
| continue-on-error: true | |
| with: | |
| check_spelling: false | |
| spelling_error_min: 1 | |
| check_urls: true | |
| url_error_min: ${{needs.set-up.outputs.url_error_min}} | |
| check_quiz_form: false | |
| quiz_error_min: 1 | |
| sort_dictionary: false | |
| issue-maker: | |
| name: Create issue | |
| needs: url-check | |
| if: needs.url-check.outputs.status == 'failure' # Proceed to make an issue if the checker above failed anywhere | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # Delete the branch if this has been run before | |
| - name: Delete branch locally and remotely | |
| run: git push origin --delete periodic-url-error || echo "No branch to delete" | |
| # Make the branch fresh | |
| - name: Make the branch fresh | |
| run: | | |
| git config --global --add safe.directory $GITHUB_WORKSPACE | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| echo branch doesnt exist | |
| git checkout -b periodic-url-error || echo branch exists | |
| git push --set-upstream origin periodic-url-error || echo echo branch exists remotely | |
| shell: bash | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ottr-check-reports | |
| - name: Declare file path and time | |
| id: check-report | |
| run: | | |
| error_num=$(cat url_checks.tsv | wc -l) | |
| error_num="$((error_num-1))" | |
| echo "error_num=$error_num" >> $GITHUB_OUTPUT | |
| echo "error_url=https://github.com/${GITHUB_REPOSITORY}/blob/periodic-url-error/url_checks.tsv" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Print out error variables | |
| run: | | |
| echo ${{ steps.check-report.outputs.error_url }} | |
| echo ${{ steps.check-report.outputs.error_num }} | |
| - name: Commit URL errors file | |
| env: | |
| GH_PAT: ${{ secrets.GH_PAT }} | |
| run: | | |
| git add --force url_checks.tsv | |
| git commit -m 'Add URL check file' || echo "No changes to commit" | |
| git push --set-upstream origin periodic-url-error || echo echo branch exists remotely | |
| - name: Make the issue | |
| uses: JasonEtco/create-an-issue@v2 | |
| with: | |
| filename: .github/ISSUE_TEMPLATE/url-error.md | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| FILE_URL: ${{ steps.check-report.outputs.error_url }} | |
| ERROR_NUM: ${{ steps.check-report.outputs.error_num }} |