From 76e9fd8ee11a6784bdc8c4b19d4e407972725332 Mon Sep 17 00:00:00 2001 From: Maddie <52103563+maddie480@users.noreply.github.com> Date: Wed, 3 Jan 2024 23:55:26 +0100 Subject: [PATCH] Create wiki_checks.yml --- .github/workflows/wiki_checks.yml | 152 ++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 .github/workflows/wiki_checks.yml diff --git a/.github/workflows/wiki_checks.yml b/.github/workflows/wiki_checks.yml new file mode 100644 index 0000000..831bff0 --- /dev/null +++ b/.github/workflows/wiki_checks.yml @@ -0,0 +1,152 @@ +name: Wiki Quality Checks + +on: + workflow_dispatch: + schedule: + - cron: "0 18 * * 1,3,5" + +jobs: + test: + name: Run Quality Checks + runs-on: ubuntu-22.04 + steps: + - name: Clone GitHub Wiki + id: checkout + uses: actions/checkout@v3 + with: + repository: ${{ github.repository }}.wiki + + + - name: Install pandoc and xmllint + id: setup-parsers + run: | + sudo apt-get update + sudo apt-get install pandoc libxml2-utils + + - name: Verify link integrity + id: check-link-integrity + if: (success() || failure()) && steps.setup-parsers.outcome == 'success' + run: | + set -o pipefail + ./.scripts/check-markdown-links | ./.scripts/log-github | \ + tee >(wc -l | sed 's/^/msg-count=/' >> $GITHUB_OUTPUT) + + + - name: Check marked external links + id: check-external-link-indicators + if: (success() || failure()) && steps.checkout.outcome == 'success' + run: | + # set -o pipefail + ./.scripts/check-link-indicators | ./.scripts/log-github --level notice | \ + tee >(wc -l | sed 's/^/msg-count=/' >> $GITHUB_OUTPUT) + exit 0 + + + - name: Install linters + id: setup-linters + if: (success() || failure()) && steps.checkout.outcome == 'success' + run: | + sudo apt-get install yamllint + + - name: Lint markdown code blocks + id: lint-code-blocks + if: (success() || failure()) && steps.setup-linters.outcome == 'success' + run: | + set -o pipefail + ./.scripts/lint-code-blocks | ./.scripts/log-github | \ + tee >(wc -l | sed 's/^/msg-count=/' >> $GITHUB_OUTPUT) + + + - name: Install git-filter-repo + id: setup-git-filter-repo + if: (success() || failure()) && steps.checkout.outcome == 'success' + run: | + sudo apt-get install git-filter-repo + + - name: Check for renamed files + id: check-renamed-files + if: (success() || failure()) && steps.setup-git-filter-repo.outcome == 'success' + run: | + # set -o pipefail + ./.scripts/check-renamed-files | ./.scripts/log-github --level warning | \ + tee >(wc -l | sed 's/^/msg-count=/' >> $GITHUB_OUTPUT) + exit 0 + + + - name: Check for duplicate files + id: check-duplicate-files + if: (success() || failure()) && steps.checkout.outcome == 'success' + run: | + set -o pipefail + ./.scripts/check-duplicate-files | ./.scripts/log-github | \ + tee >(wc -l | sed 's/^/msg-count=/' >> $GITHUB_OUTPUT) + + + - name: Report issues + if: failure() + env: + WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} + STEPS_CONTEXT: ${{ toJSON(steps) }} + run: | + WORKFLOW_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + echo "$STEPS_CONTEXT" | jq --raw-output \ + --arg workflow_url "$WORKFLOW_URL" \ + --arg job_url "$WORKFLOW_URL/jobs/$GITHUB_JOB" \ + --arg timestamp "$(date --iso-8601=minutes)" \ + ' + { embeds: [ + ([ + to_entries[] | + select( + ( + .key == "checkout" or + (.key | startswith("setup-")) + ) and .value.outcome != "success" + ) | + { + name: .key, + value: .value.outcome, + inline: false, + } + ] | if . | any then . | { + title: "Everest Wiki Workflow Run", + description: "**:rotating_light:!!SETUP FAILED!!:rotating_light:**", + url: $job_url, + color: 16711680, + fields: ., + timestamp: $timestamp, + footer: { + text: "This Action is run Mon/Wed/Fri at 18:00UTC" + } + } else empty end), + ([ + to_entries[] | + select( + ( + .key == "checkout" or + (.key | startswith("setup-")) + ) | not + ) | + { + name: .key, + value: ( + .value.outcome + + if .value.outcome == "failure" then + " (" + .value.outputs["msg-count"] + " issues)" + else "" end + ), + inline: false, + } + ] | { + title: "Everest Wiki Workflow Run", + description: "**Checks Failed:**", + url: $workflow_url, + color: 16711680, + fields: ., + timestamp: $timestamp, + footer: { + text: "This Action is run Mon/Wed/Fri at 18:00UTC" + } + }) + ], allowed_mentions: ({parse: []})} + ' | curl -X POST -H "Content-Type: application/json" --data @- "$WEBHOOK_URL"