Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix(workflows): remove tags only if the PR has been merged into the main branch

peaklabs-dev1b62e1f11786
diff --git a/.github/workflows/chore-remove-labels-and-assignees-on-close.yml b/.github/workflows/chore-remove-labels-and-assignees-on-close.yml
index ea097e328c..a3c299b5ea 100644
--- a/.github/workflows/chore-remove-labels-and-assignees-on-close.yml
+++ b/.github/workflows/chore-remove-labels-and-assignees-on-close.yml
@@ -19,8 +19,12 @@ jobs:
script: |
const { owner, repo } = context.repo;
- async function processIssue(issueNumber) {
+ async function processIssue(issueNumber, isFromPR = false, prBaseBranch = null) {
try {
+ if (isFromPR && prBaseBranch !== 'main') {
+ return;
+ }
+
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
owner,
repo,
@@ -59,19 +63,19 @@ jobs:
}
}
- if (context.eventName === 'issues' || context.eventName === 'pull_request' || context.eventName === 'pull_request_target') {
- const issue = context.payload.issue || context.payload.pull_request;
- await processIssue(issue.number);
+ if (context.eventName === 'issues') {
+ await processIssue(context.payload.issue.number);
}
if (context.eventName === 'pull_request' || context.eventName === 'pull_request_target') {
const pr = context.payload.pull_request;
- if (pr.body) {
+ await processIssue(pr.number);
+ if (pr.merged && pr.base.ref === 'main' && pr.body) {
const issueReferences = pr.body.match(/#(\d+)/g);
if (issueReferences) {
for (const reference of issueReferences) {
const issueNumber = parseInt(reference.substring(1));
- await processIssue(issueNumber);
+ await processIssue(issueNumber, true, pr.base.ref);
}
}
}