GeezerVison is showing github.com — chore(maintenance): validate acknowledgement section is present (#2112) · wuodar/powertools-lambda-python@104be8f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/scripts/constants.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,6 +24,9 @@ module.exports = Object.freeze({ | 24 | 24 | /** @type {string} */ | 25 | 25 | "LABEL_BLOCK_REASON": "need-issue", | 26 | 26 |
| | 27 | + /** @type {string} */ | | 28 | + "LABEL_BLOCK_MISSING_LICENSE_AGREEMENT": "need-license-agreement-acknowledge", | | 29 | + | 27 | 30 | /** @type {string} */ | 28 | 31 | "LABEL_PENDING_RELEASE": "pending-release", | 29 | 32 |
| |
Collapse file Copy file name to clipboard +41Lines changed: 41 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +const { | | 2 | + PR_ACTION, | | 3 | + PR_AUTHOR, | | 4 | + PR_BODY, | | 5 | + PR_NUMBER, | | 6 | + IGNORE_AUTHORS, | | 7 | + LABEL_BLOCK, | | 8 | + LABEL_BLOCK_MISSING_LICENSE_AGREEMENT | | 9 | +} = require("./constants") | | 10 | + | | 11 | +module.exports = async ({github, context, core}) => { | | 12 | + if (IGNORE_AUTHORS.includes(PR_AUTHOR)) { | | 13 | + return core.notice("Author in IGNORE_AUTHORS list; skipping...") | | 14 | + } | | 15 | + | | 16 | + if (PR_ACTION != "opened") { | | 17 | + return core.notice("Only newly open PRs are labelled to avoid spam; skipping") | | 18 | + } | | 19 | + | | 20 | + const RELATED_ACK_SECTION_REGEX = /## Acknowledgment\n\nBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.\n\n\*\*Disclaimer\*\*: We value your time and bandwidth\. As such, any pull requests created on non-triaged issues might not be successful\./; | | 21 | + | | 22 | + const isMatch = RELATED_ACK_SECTION_REGEX.exec(PR_BODY); | | 23 | + if (isMatch == null) { | | 24 | + core.info(`No acknowledgement section found, maybe the author didn't use the template but there is one.`) | | 25 | + | | 26 | + let msg = "No acknowledgement section found. Please make sure you used the template to open a PR and didn't remove the acknowledgment section. Check the template here: https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/.github/PULL_REQUEST_TEMPLATE.md#acknowledgment"; | | 27 | + await github.rest.issues.createComment({ | | 28 | + owner: context.repo.owner, | | 29 | + repo: context.repo.repo, | | 30 | + body: msg, | | 31 | + issue_number: PR_NUMBER, | | 32 | + }); | | 33 | + | | 34 | + return await github.rest.issues.addLabels({ | | 35 | + issue_number: PR_NUMBER, | | 36 | + owner: context.repo.owner, | | 37 | + repo: context.repo.repo, | | 38 | + labels: [LABEL_BLOCK, LABEL_BLOCK_MISSING_LICENSE_AGREEMENT] | | 39 | + }) | | 40 | + } | | 41 | +} |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/on_opened_pr.yml +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 32 | 32 | script: | | 33 | 33 | const script = require('.github/scripts/label_missing_related_issue.js') | 34 | 34 | await script({github, context, core}) | | 35 | + check_acknowledge_section: | | 36 | + needs: get_pr_details | | 37 | + runs-on: ubuntu-latest | | 38 | + steps: | | 39 | + - uses: actions/checkout@v3 | | 40 | + - name: "Ensure acknowledgement section is present" | | 41 | + uses: actions/github-script@v6 | | 42 | + env: | | 43 | + PR_BODY: ${{ needs.get_pr_details.outputs.prBody }} | | 44 | + PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }} | | 45 | + PR_ACTION: ${{ needs.get_pr_details.outputs.prAction }} | | 46 | + PR_AUTHOR: ${{ needs.get_pr_details.outputs.prAuthor }} | | 47 | + with: | | 48 | + github-token: ${{ secrets.GITHUB_TOKEN }} | | 49 | + script: | | | 50 | + const script = require('.github/scripts/label_missing_acknowledgement_section.js') | | 51 | + await script({github, context, core}) |
|