Skip to content

Commit d2f67ec

Browse files
committed
Include a branch name (from the input) when generating artifact names
since we may end up trying to create artifacts with the same names for different branches when running a scheduled workflow
1 parent 5ea1eb9 commit d2f67ec

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ jobs:
9191
run: |
9292
echo "yearmonth=$(/bin/date -u '+%Y-%m')" >> "$GITHUB_OUTPUT"
9393
shell: bash
94+
- name: Sanitize the branch name
95+
# So that if we end up using the branch name in the artifact name we won't have any unexpected chars in the name
96+
shell: bash
97+
id: current-branch-suffix
98+
run: |
99+
echo "value=$(echo ${{ inputs.branch }}" | sed -E 's/[^A-Za-z0-9._-]+/-/g')" >> "$GITHUB_OUTPUT"
94100
- name: Cache Gradle downloads
95101
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
96102
id: cache-gradle
@@ -121,7 +127,7 @@ jobs:
121127
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
122128
if: failure()
123129
with:
124-
name: reports-examples-${{ matrix.db }}
130+
name: reports-examples-${{ matrix.db }}-${{steps.current-branch-suffix.outputs.value}}
125131
path: './**/build/reports/'
126132

127133
test_dbs:
@@ -140,6 +146,12 @@ jobs:
140146
run: |
141147
echo "yearmonth=$(/bin/date -u '+%Y-%m')" >> "$GITHUB_OUTPUT"
142148
shell: bash
149+
- name: Sanitize the branch name
150+
# So that if we end up using the branch name in the artifact name we won't have any unexpected chars in the name
151+
shell: bash
152+
id: current-branch-suffix
153+
run: |
154+
echo "value=$(echo ${{ inputs.branch }}" | sed -E 's/[^A-Za-z0-9._-]+/-/g')" >> "$GITHUB_OUTPUT"
143155
- name: Cache Gradle downloads
144156
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
145157
id: cache-gradle
@@ -171,7 +183,7 @@ jobs:
171183
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
172184
if: failure()
173185
with:
174-
name: reports-db-${{ matrix.db }}
186+
name: reports-db-${{ matrix.db }}-${{steps.current-branch-suffix.outputs.value}}
175187
path: './**/build/reports/'
176188

177189
test_jdks:
@@ -204,7 +216,12 @@ jobs:
204216
run: |
205217
echo "yearmonth=$(/bin/date -u '+%Y-%m')" >> "$GITHUB_OUTPUT"
206218
shell: bash
207-
219+
- name: Sanitize the branch name
220+
# So that if we end up using the branch name in the artifact name we won't have any unexpected chars in the name
221+
shell: bash
222+
id: current-branch-suffix
223+
run: |
224+
echo "value=$(echo ${{ inputs.branch }}" | sed -E 's/[^A-Za-z0-9._-]+/-/g')" >> "$GITHUB_OUTPUT"
208225
- name: Generate cache key
209226
id: cache-key
210227
run: |
@@ -295,5 +312,5 @@ jobs:
295312
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
296313
if: failure()
297314
with:
298-
name: reports-java${{ matrix.java.name }}
315+
name: reports-java${{ matrix.java.name }}-${{steps.current-branch-suffix.outputs.value}}
299316
path: './**/build/reports/'

0 commit comments

Comments
 (0)