Skip to content

Commit 9d40743

Browse files
committed
chore(ci): updating templates and actions for automation
1 parent 595fcc4 commit 9d40743

File tree

5 files changed

+106
-15
lines changed

5 files changed

+106
-15
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- markdownlint-disable MD041 MD043 -->
21
**Issue number:**
32

43
## Summary
@@ -20,19 +19,6 @@ Please leave checklist items unchecked if they do not apply to your change.
2019
* [ ] Changes are documented
2120
* [ ] PR title follows [conventional commit semantics](https://github.com/aws-samples/aws-serverless-developer-experience-workshop-dotnet/blob/develop/.github/semantic.yml)
2221

23-
24-
<details>
25-
<summary>Is this a breaking change?</summary>
26-
27-
**RFC issue number**:
28-
29-
Checklist:
30-
31-
* [ ] Migration process documented
32-
* [ ] Implement warnings (if it can live side by side)
33-
34-
</details>
35-
3622
## Acknowledgment
3723

3824
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

.github/auto_assign.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ reviewers:
1212
# Set 0 to add all the reviewers (default: 0)
1313
numberOfReviewers: 1
1414

15+
# A list of assignees, overrides reviewers if set
16+
# assignees:
17+
- @aws-samples/aws-serverless-developer-experience-workshop-dotnet
1518

1619
# A number of assignees to add to the pull request
1720
# Set to 0 to add all of the assignees.
1821
# Uses numberOfReviewers if unset.
19-
# numberOfAssignees: 2
22+
numberOfAssignees: 0
2023

2124
# A list of keywords to be skipped the process that add reviewers if pull requests include it
2225
# skipKeywords:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 = /By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice./;
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+
}

.github/workflows/auto_assign.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'Auto Assign'
2+
on:
3+
pull_request:
4+
types: [opened, ready_for_review]
5+
6+
jobs:
7+
add-reviews:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: kentaro-m/auto-assign-action@v1.2.5

.github/workflows/on_opened_pr.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: On new PR
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Record PR details"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
get_pr_details:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
uses: ./.github/workflows/reusable_export_pr_details.yml
13+
with:
14+
record_pr_workflow_id: ${{ github.event.workflow_run.id }}
15+
workflow_origin: ${{ github.event.repository.full_name }}
16+
secrets:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
check_related_issue:
19+
needs: get_pr_details
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: "Ensure related issue is present"
24+
uses: actions/github-script@v6
25+
env:
26+
PR_BODY: ${{ needs.get_pr_details.outputs.prBody }}
27+
PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }}
28+
PR_ACTION: ${{ needs.get_pr_details.outputs.prAction }}
29+
PR_AUTHOR: ${{ needs.get_pr_details.outputs.prAuthor }}
30+
with:
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
script: |
33+
const script = require('.github/scripts/label_missing_related_issue.js')
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})

0 commit comments

Comments
 (0)