Skip to content

Commit c131c18

Browse files
committed
Add optional githubShaOverride for schedule
1 parent 0582759 commit c131c18

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.github/workflows/trigger-gitlab-pipeline.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ on:
1616
required: false
1717
default: true
1818
type: boolean
19+
github-sha-override:
20+
description: "Option to override the SHA"
21+
required: false
22+
type: string
23+
default: ""
1924
secrets:
2025
ci-api-v4-url:
2126
description: 'GitLab API v4 root URL'
@@ -72,6 +77,4 @@ jobs:
7277
ACCESS_TOKEN: ${{ secrets.access-token }}
7378
TRIGGER_TOKEN: ${{ secrets.trigger-token }}
7479
PROJECT_ID: ${{ secrets.project-id }}
75-
76-
77-
80+
GITHUB_SHA_OVERRIDE: ${{ inputs.github-sha-override }}

index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ function getEnv (name) {
123123
return val;
124124
}
125125

126+
function getOptionalEnv (name) {
127+
return process.env[name] || '';
128+
}
129+
126130
function getBooleanEnv (name) {
127131
const trueValue = ['true', 'True', 'TRUE'];
128132
const falseValue = ['false', 'False', 'FALSE'];
@@ -140,7 +144,8 @@ async function main () {
140144
projectId: getEnv('PROJECT_ID'),
141145
triggeredRef: getEnv('TRIGGERED_REF'),
142146
schedule: getBooleanEnv('SCHEDULE'),
143-
cancelOutdatedPipelines: getBooleanEnv('CANCEL_OUTDATED_PIPELINES')
147+
cancelOutdatedPipelines: getBooleanEnv('CANCEL_OUTDATED_PIPELINES'),
148+
githubShaOverride: getOptionalEnv('GITHUB_SHA_OVERRIDE')
144149
};
145150

146151
const githubConfig = {
@@ -157,6 +162,10 @@ async function main () {
157162
break;
158163
case 'push':
159164
case 'schedule':
165+
if (inputConfig.githubShaOverride) {
166+
githubConfig.githubSha = inputConfig.githubShaOverride;
167+
}
168+
break;
160169
case 'merge_group':
161170
break;
162171
default:

0 commit comments

Comments
 (0)