Skip to content

Commit 68c77f7

Browse files
szymon-czaprackisjanc
authored andcommitted
ci: Remove env variable from workflow
Using env variables in workflow is quirky. Instead make condition use plain literal. Change trigger option, previously labeled action triggered this, we don't want this.
1 parent 9a6f47d commit 68c77f7

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

.github/workflows/remove_ci_label.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,45 @@
1919

2020
name: Remove informative CI status
2121

22-
on:
23-
pull_request:
24-
types: [labeled]
22+
on: [push, pull_request]
2523

2624
permissions:
2725
contents: read
2826
issues: write
2927
pull-requests: write
3028

31-
env:
32-
LABEL: needs-ci-approval
33-
3429
jobs:
3530
remove-ci-label:
36-
if: ${{ github.event.label.name == env.LABEL }}
3731
runs-on: ubuntu-latest
3832
steps:
3933
- uses: actions/github-script@v7
4034
with:
4135
script: |
36+
const label = 'needs-ci-approval';
37+
38+
// List current labels on the PR
39+
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
40+
...context.repo,
41+
issue_number: context.issue.number,
42+
});
43+
44+
const hasLabel = labels.some(l => l.name === label);
45+
if (!hasLabel) {
46+
core.info(`'${label}' not present — nothing to do.`);
47+
return;
48+
}
49+
50+
// Remove the label if present
4251
try {
4352
await github.rest.issues.removeLabel({
4453
...context.repo,
4554
issue_number: context.issue.number,
46-
name: process.env.LABEL,
55+
name: label,
4756
});
48-
core.info(`Removed '${process.env.LABEL}' from PR #${context.issue.number}.`);
57+
core.info(`Removed '${label}' from PR #${context.issue.number}.`);
4958
} catch (e) {
5059
if (e.status === 404) {
51-
core.info(`Label '${process.env.LABEL}' not present; nothing to remove.`);
60+
core.info(`'${label}' already gone.`);
5261
} else {
5362
throw e;
5463
}

0 commit comments

Comments
 (0)