Skip to content

minor editing changes #2703

minor editing changes

minor editing changes #2703

Workflow file for this run

name: Run Tests
on:
pull_request_target:
permissions:
contents: read
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: check urls
uses: urlstechie/urlchecker-action@master
with:
subfolder: docs
file_types: .en.md,.md
include_files: '\/([\w-]+)\.(en\.)?md'
exclude_patterns: 'avatars.githubusercontent.com,example.com,your-server-ip,your-server-hostname,nginx-server,apache-server,site1.com,site2.com,site.com,$releasever,proxy.rocky.lan,repo.rocky.lan,zfs-release,$host$request,fileserver.rockylinux.lan,your_fork_name,rundeck.rockylinux.org,manickathan.ch,breakingpitt.es,download.example,192.168,172.16,127.0.0.1,localhost,download.rockylinux.org,cyber.gov.au,herokuapp.com,rpa.st,home.arpa,SERVER_IP,dev.mysql.com'
# NOTE:(sspencerwire) 2022-10-25, cyber.gov.au added to excludes as a known good URL that will not pass the test. Probably blocking GitHub
print_all: false
retry_count: 2
timeout: 7
force_pass: true # Don't block deployment
save: "output.csv"
verbose: true
- name: Affected URLs
id: gather
run: |
OUT="$(awk -F, '((NR>1 && $2=="failed") || NR==1 ){print}' output.csv)"
echo 'URLS<<EOF' >> $GITHUB_OUTPUT
echo $OUT >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "COUNT_U=$(( $(wc -l <<<$OUT) - 1 ))" >> $GITHUB_OUTPUT
outputs:
URLS: ${{ steps.gather.outputs.URLS }}
COUNT_U: ${{ steps.gather.outputs.COUNT_U }}
comment:
name: "Comment on PR"
needs: test
runs-on: ubuntu-latest
steps:
- name: Comment
uses: actions/github-script@v5
env:
URLS: "${{ needs.test.outputs.URLS }}"
COUNT_U: "${{ needs.test.outputs.COUNT_U }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const count_u = process.env.COUNT_U.toString();
const commentText = 'Test results for ' + context.payload.pull_request.head.sha + ":\n\nNumber of broken URLs: " + count_u + "\n";
const output = process.env.URLS.toString().trimEnd();
var body = "<details>\n<summary>" + commentText + "</summary>\n\n```csv\n" + output + "\n```\n\n</details>";
const fs = require('fs');
fs.writeFileSync(process.env.GITHUB_STEP_SUMMARY, body);
needNewComment = true;
console.log('Reviewing existing comments...');
for await (const { data: comments } of github.paginate.iterator(
github.rest.issues.listComments,
{
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
}
)) {
for (const comment of comments) {
if (comment.user.login === 'github-actions[bot]') {
if (needNewComment && comment.body.includes(commentText)) {
needNewComment = false;
} else {
console.log('Deleting comment: ' + comment.id);
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
});
}
}
}
}
if (needNewComment) {
console.log('Creating new comment...');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: body,
});
}