Skip to content

Commit 164fd51

Browse files
committed
make manual vs auto ref a config option
1 parent b2523d8 commit 164fd51

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

.github/workflows/compute-workflow-parameters.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,37 @@ on:
9999
value: ${{ jobs.main.outputs.ref }}
100100

101101
jobs:
102-
main:
103-
name: Get parameters
102+
manual_ref:
103+
if: inputs.ref != 'auto'
104+
run: |
105+
if [[ "${{ inputs.ref }}" != "" ]]; then
106+
echo "ref=${{ inputs.ref }}" >> $GITHUB_OUTPUT
107+
elif [[ "${{ github.repository }}" == "DataDog/system-tests" ]]; then
108+
echo "ref=" >> $GITHUB_OUTPUT
109+
else
110+
echo "ref=main }}" >> $GITHUB_OUTPUT
111+
fi
112+
113+
auto_ref:
114+
if: inputs.ref == 'auto'
104115
runs-on: ubuntu-latest
105116
permissions:
106117
id-token: write # required to get an oidc token
107118
contents: read
119+
steps:
120+
- uses: ChristopherHX/oidc@73eee1ff03fdfce10eda179f617131532209edbd
121+
id: oidc
122+
- name: Compute ref
123+
id: compute_ref
124+
run: ref=${{ steps.oidc.outputs.job_workflow_repo_ref }}" >> $GITHUB_OUTPUT
125+
126+
main:
127+
if: always() && !failure() && !cancelled()
128+
name: Get parameters
129+
runs-on: ubuntu-latest
130+
needs:
131+
- manual_ref
132+
- auto_ref
108133
outputs:
109134
endtoend_defs_parallel_enable: ${{ steps.main.outputs.endtoend_defs_parallel_enable }}
110135
endtoend_defs_parallel_weblogs: ${{ steps.main.outputs.endtoend_defs_parallel_weblogs }}
@@ -122,18 +147,9 @@ jobs:
122147
unique_id: ${{ steps.unique_id.outputs.value }}
123148
ref: ${{ steps.compute_ref.outputs.ref }}
124149
steps:
125-
- uses: ChristopherHX/oidc@45e798774435c73c1bbf62e2df0ba60f95cdb457
126-
id: oidc
127150
- name: Compute ref
128151
id: compute_ref
129-
run: |
130-
if [[ "${{ inputs.ref }}" != "" ]]; then
131-
echo "ref=${{ inputs.ref }}" >> $GITHUB_OUTPUT
132-
elif [[ "${{ github.repository }}" == "DataDog/system-tests" ]]; then
133-
echo "ref=" >> $GITHUB_OUTPUT
134-
else
135-
echo "ref=${{ steps.oidc.outputs.job_workflow_repo_ref }}" >> $GITHUB_OUTPUT
136-
fi
152+
run: echo "ref=${{ jobs.auto_ref.outputs.ref || jobs.manual_ref.outputs.ref }}" >> $GITHUB_OUTPUT
137153
- name: Checkout
138154
uses: actions/checkout@v4
139155
with:

0 commit comments

Comments
 (0)