Skip to content

Commit fc3df7a

Browse files
authored
fix(ci): inject PR_LABELS env for PR Label automation (aws-powertools#3819)
* fix(parameters): make cache aware of single vs multiple calls Signed-off-by: heitorlessa <[email protected]> * chore: cleanup, add test for single and nested Signed-off-by: heitorlessa <[email protected]> * fix(ci): inject PR_LABELS env Signed-off-by: heitorlessa <[email protected]> * chore: init PR_LABELS env with default to prevent failure (no labels) Signed-off-by: heitorlessa <[email protected]> --------- Signed-off-by: heitorlessa <[email protected]>
1 parent 40cd127 commit fc3df7a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.github/scripts/constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ module.exports = Object.freeze({
1818
/** @type {string} */
1919
"PR_IS_MERGED": process.env.PR_IS_MERGED || "false",
2020

21+
/** @type {string} */
22+
"PR_LABELS": process.env.PR_LABELS || "",
23+
2124
/** @type {string} */
2225
"LABEL_BLOCK": "do-not-merge",
2326

.github/scripts/label_pr_based_on_title.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { PR_NUMBER, PR_TITLE } = require("./constants")
1+
const { PR_NUMBER, PR_TITLE, PR_LABELS } = require("./constants")
22

33
module.exports = async ({github, context, core}) => {
44
const FEAT_REGEX = /feat(\((.+)\))?(:.+)/
@@ -18,10 +18,9 @@ module.exports = async ({github, context, core}) => {
1818
}
1919

2020
// get PR labels from env
21-
const prLabels = process.env.PR_LABELS.replaceAll("\"", "").split(",");
21+
const prLabels = PR_LABELS.replaceAll("\"", "").split(",");
2222
const labelKeys = Object.keys(labels);
2323

24-
// Maintenance: We should keep track of modified PRs in case their titles change
2524
let miss = 0;
2625
try {
2726
for (const label in labels) {

.github/workflows/label_pr_on_title.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
env:
5757
PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }}
5858
PR_TITLE: ${{ needs.get_pr_details.outputs.prTitle }}
59+
PR_LABELS: ${{ needs.get_pr_details.outputs.prLabels }}
5960
with:
6061
github-token: ${{ secrets.GITHUB_TOKEN }}
6162
# This safely runs in our base repo, not on fork

0 commit comments

Comments
 (0)