Skip to content

Commit

Permalink
Don't upload multiple times to same artifact in label sync workflows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
per1234 committed Oct 14, 2024
1 parent f5c9530 commit a4efefd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/sync-labels-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
# See: https://github.com/actions/setup-node/#readme
NODE_VERSION: 16.x
CONFIGURATIONS_FOLDER: .github/label-configuration-files
CONFIGURATIONS_ARTIFACT: label-configuration-files
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-

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

sync:
needs: download
Expand Down Expand Up @@ -123,16 +123,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download configuration files artifact
- name: Download configuration file artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
merge-multiple: true
pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
path: ${{ env.CONFIGURATIONS_FOLDER }}

- name: Remove unneeded artifact
- name: Remove unneeded artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*

- name: Setup Node.js
uses: actions/setup-node@v4
Expand Down
13 changes: 7 additions & 6 deletions workflow-templates/sync-labels-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
# See: https://github.com/actions/setup-node/#readme
NODE_VERSION: 16.x
CONFIGURATIONS_FOLDER: .github/label-configuration-files
CONFIGURATIONS_ARTIFACT: label-configuration-files
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-

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

sync:
needs: download
Expand Down Expand Up @@ -123,16 +123,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download configuration files artifact
- name: Download configuration file artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
merge-multiple: true
pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
path: ${{ env.CONFIGURATIONS_FOLDER }}

- name: Remove unneeded artifact
- name: Remove unneeded artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*

- name: Setup Node.js
uses: actions/setup-node@v4
Expand Down
12 changes: 6 additions & 6 deletions workflow-templates/sync-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:

env:
CONFIGURATIONS_FOLDER: .github/label-configuration-files
CONFIGURATIONS_ARTIFACT: label-configuration-files
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-

jobs:
check:
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
*.yaml
*.yml
if-no-files-found: error
name: ${{ env.CONFIGURATIONS_ARTIFACT }}-${{ matrix.filename }}
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}${{ matrix.filename }}

sync:
needs: download
Expand Down Expand Up @@ -113,17 +113,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download configuration files artifact
- name: Download configuration file artifacts
uses: actions/download-artifact@v4
with:
pattern: ${{ env.CONFIGURATIONS_ARTIFACT }}-*
merge-multiple: true
pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
path: ${{ env.CONFIGURATIONS_FOLDER }}

- name: Remove unneeded artifact
- name: Remove unneeded artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}-*
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*

- name: Merge label configuration files
run: |
Expand Down

0 comments on commit a4efefd

Please sign in to comment.