Skip to content

Commit 756d016

Browse files
Refactor environment variable usage in workflow (#1259)
1 parent 13e2695 commit 756d016

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.github/workflows/combine-dependabot-prs.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ jobs:
4141
for (const pull of pulls) {
4242
const branch = pull['head']['ref'];
4343
console.log('Pull for branch: ' + branch);
44-
if (branch.startsWith('${{ github.event.inputs.branchPrefix }}')) {
44+
if (branch.startsWith('${process.env.BRANCH_PREFIX}')) {
4545
console.log('Branch matched: ' + branch);
4646
statusOK = true;
47-
if(${{ github.event.inputs.mustBeGreen }}) {
47+
if("true" == process.env.MUST_BE_GREEN}) {
4848
console.log('Checking green status: ' + branch);
4949
const statuses = await github.paginate('GET /repos/{owner}/{repo}/commits/{ref}/status', {
5050
owner: context.repo.owner,
@@ -65,7 +65,7 @@ jobs:
6565
for(const label of labels) {
6666
const labelName = label['name'];
6767
console.log('Checking label: ' + labelName);
68-
if(labelName == '${{ github.event.inputs.ignoreLabel }}') {
68+
if(labelName == '${process.env.IGNORE_LABEL}') {
6969
console.log('Discarding ' + branch + ' with label ' + labelName);
7070
statusOK = false;
7171
}
@@ -88,6 +88,10 @@ jobs:
8888
combined = branches.join(' ')
8989
console.log('Combined: ' + combined);
9090
return combined
91+
env:
92+
BRANCH_PREFIX: ${{ github.event.inputs.branchPrefix }}
93+
MUST_BE_GREEN: ${{ github.event.inputs.mustBeGreen }}
94+
IGNORE_LABEL: ${{ github.event.inputs.ignoreLabel }}
9195

9296
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
9397
with:
@@ -126,6 +130,8 @@ jobs:
126130
name: Create Combined Pull Request
127131
env:
128132
PRS_STRING: ${{ steps.fetch-branch-names.outputs.prs-string }}
133+
COMBINE_BRANCH_NAME: ${{ github.event.inputs.combineBranchName }}
134+
BASE_BRANCH: ${{ steps.fetch-branch-names.outputs.base-branch }}
129135
with:
130136
github-token: ${{ steps.get_token.outputs.app_token }}
131137
script: |
@@ -135,7 +141,7 @@ jobs:
135141
owner: context.repo.owner,
136142
repo: context.repo.repo,
137143
title: '🛡️ Security Updates',
138-
head: '${{ github.event.inputs.combineBranchName }}',
139-
base: '${{ steps.fetch-branch-names.outputs.base-branch }}',
144+
head: '${process.env.COMBINE_BRANCH_NAME}',
145+
base: '${process.env.BASE_BRANCH}',
140146
body: body
141147
});

0 commit comments

Comments
 (0)