зеркало из https://github.com/github/docs.git
Update action for broken link reports to add context to and close prior reports (#20213)
This commit is contained in:
Родитель
adc1b8ed6c
Коммит
92fd200e2b
|
@ -23,7 +23,6 @@ export default [
|
||||||
'juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8',
|
'juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8',
|
||||||
'juliangruber/find-pull-request-action@db875662766249c049b2dcd85293892d61cb0b51', // v1.5.0
|
'juliangruber/find-pull-request-action@db875662766249c049b2dcd85293892d61cb0b51', // v1.5.0
|
||||||
'juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512',
|
'juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512',
|
||||||
'lee-dohm/close-matching-issues@22002609b2555fe18f52b8e2e7c07cbf5529e8a8',
|
|
||||||
'lee-dohm/no-response@9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb',
|
'lee-dohm/no-response@9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb',
|
||||||
'pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07', // v0.12.0
|
'pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07', // v0.12.0
|
||||||
'peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e',
|
'peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e',
|
||||||
|
|
|
@ -14,6 +14,11 @@ jobs:
|
||||||
name: Check all links
|
name: Check all links
|
||||||
if: github.repository == 'github/docs-internal'
|
if: github.repository == 'github/docs-internal'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
|
||||||
|
REPORT_AUTHOR: docubot
|
||||||
|
REPORT_LABEL: broken link report
|
||||||
|
REPORT_REPOSITORY: github/docs-content
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
||||||
- name: npm ci
|
- name: npm ci
|
||||||
|
@ -27,27 +32,58 @@ jobs:
|
||||||
name: Get title for issue
|
name: Get title for issue
|
||||||
id: check
|
id: check
|
||||||
run: echo "::set-output name=title::$(head -1 broken_links.md)"
|
run: echo "::set-output name=title::$(head -1 broken_links.md)"
|
||||||
- if: ${{ failure() }}
|
|
||||||
name: Close previous report
|
|
||||||
uses: lee-dohm/close-matching-issues@22002609b2555fe18f52b8e2e7c07cbf5529e8a8
|
|
||||||
with:
|
|
||||||
query: 'label:"broken link report"'
|
|
||||||
token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
|
|
||||||
- if: ${{ failure() }}
|
- if: ${{ failure() }}
|
||||||
name: Create issue from file
|
name: Create issue from file
|
||||||
id: broken-link-report
|
id: broken-link-report
|
||||||
uses: peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e
|
uses: peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
|
token: ${{ env.GITHUB_TOKEN }}
|
||||||
|
|
||||||
title: ${{ steps.check.outputs.title }}
|
title: ${{ steps.check.outputs.title }}
|
||||||
content-filepath: ./broken_links.md
|
content-filepath: ./broken_links.md
|
||||||
repository: github/docs-content
|
repository: ${{ env.REPORT_REPOSITORY }}
|
||||||
labels: broken link report
|
labels: ${{ env.REPORT_LABEL }}
|
||||||
- if: ${{ failure() }}
|
- if: ${{ failure() }}
|
||||||
name: Add comment to issue
|
name: Close and/or comment on old issues
|
||||||
uses: peter-evans/create-or-update-comment@5221bf4aa615e5c6e95bb142f9673a9c791be2cd
|
env:
|
||||||
with:
|
NEW_REPORT_URL: 'https://github.com/${{ env.REPORT_REPOSITORY }}/issues/${{ steps.broken-link-report.outputs.issue-number }}'
|
||||||
body: |
|
run: |
|
||||||
cc @github/docs-content
|
gh alias set list-reports "issue list \
|
||||||
issue-number: ${{ steps.broken-link-report.outputs.issue-number }}
|
--repo ${{ env.REPORT_REPOSITORY }} \
|
||||||
token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
|
--author ${{ env.REPORT_AUTHOR }} \
|
||||||
|
--label '${{ env.REPORT_LABEL }}'"
|
||||||
|
|
||||||
|
# Link to the previous report from the new report that triggered this
|
||||||
|
# workflow run.
|
||||||
|
|
||||||
|
for issue_url in $(gh list-reports \
|
||||||
|
--state all \
|
||||||
|
--limit 2 \
|
||||||
|
--json url \
|
||||||
|
--jq '.[].url' | grep -v ${{ env.NEW_REPORT_URL }}); do
|
||||||
|
gh issue comment ${{ env.NEW_REPORT_URL }} --body "⬅️ [Previous report]($issue_url)"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Link to the newer report from any older report that is still open,
|
||||||
|
# then close the older report.
|
||||||
|
|
||||||
|
for issue_url in $(gh list-reports \
|
||||||
|
--search 'no:assignee' \
|
||||||
|
--json url \
|
||||||
|
--jq '.[].url'); do
|
||||||
|
if [ "$issue_url" != "${{ env.NEW_REPORT_URL }}" ]; then
|
||||||
|
gh issue comment $issue_url --body "➡️ [Newer report](${{ env.NEW_REPORT_URL }})"
|
||||||
|
gh issue close $issue_url
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# If an old report is open and assigned to someone, link to the newer
|
||||||
|
# report without closing the old report.
|
||||||
|
|
||||||
|
for issue_url in $(gh list-reports \
|
||||||
|
--json assignees,url \
|
||||||
|
--jq '.[] | select (.assignees != []) | .url'); do
|
||||||
|
if [ "$issue_url" != "${{ env.NEW_REPORT_URL }}" ]; then
|
||||||
|
gh issue comment $issue_url --body "➡️ [Newer report](${{ env.NEW_REPORT_URL }})"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче