Skip to content

Commit a4efefd

Browse files
committed
Don't upload multiple times to same artifact in label sync workflows
The "Sync Labels" GitHub Actions workflows are configured to allow the use of multiple shared label configuration files. This is done by using a job matrix in the GitHub Actions workflow to download each of the files from the source repository in a parallel GitHub Actions workflow job. A GitHub Actions workflow artifact was used to transfer the generated files between sequential jobs in the workflow. The "actions/upload-artifact" and "actions/download-artifact" actions are used for this purpose. Previously, a single artifact was used for the transfer of all the shared label configuration files, with each of the parallel jobs uploading its own generated files to that artifact. However, support for uploading multiple times to a single artifact was dropped in version 4.0.0 of the "actions/upload-artifact" action. So it is now necessary to use a dedicated artifact for each of the builds. These can be downloaded in aggregate by using the artifact name globbing and merging features which were introduced in version 4.1.0 of the "actions/download-artifact" action.
1 parent f5c9530 commit a4efefd

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.github/workflows/sync-labels-npm.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ env:
55
# See: https://github.com/actions/setup-node/#readme
66
NODE_VERSION: 16.x
77
CONFIGURATIONS_FOLDER: .github/label-configuration-files
8-
CONFIGURATIONS_ARTIFACT: label-configuration-files
8+
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-
99

1010
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
1111
on:
@@ -89,7 +89,7 @@ jobs:
8989
*.yaml
9090
*.yml
9191
if-no-files-found: error
92-
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
92+
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}${{ matrix.filename }}
9393

9494
sync:
9595
needs: download
@@ -123,16 +123,17 @@ jobs:
123123
- name: Checkout repository
124124
uses: actions/checkout@v4
125125

126-
- name: Download configuration files artifact
126+
- name: Download configuration file artifacts
127127
uses: actions/download-artifact@v4
128128
with:
129-
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
129+
merge-multiple: true
130+
pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
130131
path: ${{ env.CONFIGURATIONS_FOLDER }}
131132

132-
- name: Remove unneeded artifact
133+
- name: Remove unneeded artifacts
133134
uses: geekyeggo/delete-artifact@v5
134135
with:
135-
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
136+
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
136137

137138
- name: Setup Node.js
138139
uses: actions/setup-node@v4

workflow-templates/sync-labels-npm.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ env:
55
# See: https://github.com/actions/setup-node/#readme
66
NODE_VERSION: 16.x
77
CONFIGURATIONS_FOLDER: .github/label-configuration-files
8-
CONFIGURATIONS_ARTIFACT: label-configuration-files
8+
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-
99

1010
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
1111
on:
@@ -89,7 +89,7 @@ jobs:
8989
*.yaml
9090
*.yml
9191
if-no-files-found: error
92-
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
92+
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}${{ matrix.filename }}
9393

9494
sync:
9595
needs: download
@@ -123,16 +123,17 @@ jobs:
123123
- name: Checkout repository
124124
uses: actions/checkout@v4
125125

126-
- name: Download configuration files artifact
126+
- name: Download configuration file artifacts
127127
uses: actions/download-artifact@v4
128128
with:
129-
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
129+
merge-multiple: true
130+
pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
130131
path: ${{ env.CONFIGURATIONS_FOLDER }}
131132

132-
- name: Remove unneeded artifact
133+
- name: Remove unneeded artifacts
133134
uses: geekyeggo/delete-artifact@v5
134135
with:
135-
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
136+
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
136137

137138
- name: Setup Node.js
138139
uses: actions/setup-node@v4

workflow-templates/sync-labels.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919

2020
env:
2121
CONFIGURATIONS_FOLDER: .github/label-configuration-files
22-
CONFIGURATIONS_ARTIFACT: label-configuration-files
22+
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-
2323

2424
jobs:
2525
check:
@@ -79,7 +79,7 @@ jobs:
7979
*.yaml
8080
*.yml
8181
if-no-files-found: error
82-
name: ${{ env.CONFIGURATIONS_ARTIFACT }}-${{ matrix.filename }}
82+
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}${{ matrix.filename }}
8383

8484
sync:
8585
needs: download
@@ -113,17 +113,17 @@ jobs:
113113
- name: Checkout repository
114114
uses: actions/checkout@v4
115115

116-
- name: Download configuration files artifact
116+
- name: Download configuration file artifacts
117117
uses: actions/download-artifact@v4
118118
with:
119-
pattern: ${{ env.CONFIGURATIONS_ARTIFACT }}-*
120119
merge-multiple: true
120+
pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
121121
path: ${{ env.CONFIGURATIONS_FOLDER }}
122122

123-
- name: Remove unneeded artifact
123+
- name: Remove unneeded artifacts
124124
uses: geekyeggo/delete-artifact@v5
125125
with:
126-
name: ${{ env.CONFIGURATIONS_ARTIFACT }}-*
126+
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
127127

128128
- name: Merge label configuration files
129129
run: |

0 commit comments

Comments
 (0)