Skip to content

Commit

Permalink
fix(ci): inject PR_LABELS env for PR Label automation (#3819)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
heitorlessa authored Feb 21, 2024
1 parent 40cd127 commit fc3df7a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module.exports = Object.freeze({
/** @type {string} */
"PR_IS_MERGED": process.env.PR_IS_MERGED || "false",

/** @type {string} */
"PR_LABELS": process.env.PR_LABELS || "",

/** @type {string} */
"LABEL_BLOCK": "do-not-merge",

Expand Down
5 changes: 2 additions & 3 deletions .github/scripts/label_pr_based_on_title.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { PR_NUMBER, PR_TITLE } = require("./constants")
const { PR_NUMBER, PR_TITLE, PR_LABELS } = require("./constants")

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

// get PR labels from env
const prLabels = process.env.PR_LABELS.replaceAll("\"", "").split(",");
const prLabels = PR_LABELS.replaceAll("\"", "").split(",");
const labelKeys = Object.keys(labels);

// Maintenance: We should keep track of modified PRs in case their titles change
let miss = 0;
try {
for (const label in labels) {
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/label_pr_on_title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
env:
PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }}
PR_TITLE: ${{ needs.get_pr_details.outputs.prTitle }}
PR_LABELS: ${{ needs.get_pr_details.outputs.prLabels }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# This safely runs in our base repo, not on fork
Expand Down

0 comments on commit fc3df7a

Please sign in to comment.