[llvm] [Github] Make issue-write workflow support reading from multiple files (PR #170411)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 3 12:24:11 PST 2025


https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/170411

>From 0d500afe8da9a64341d309e6a2561269655e094e Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Wed, 3 Dec 2025 02:47:18 +0000
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20change?=
 =?UTF-8?q?s=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7

[skip ci]
---
 .github/workflows/issue-write-test.yaml       | 25 ++++++++
 .github/workflows/issue-write.yml             |  1 +
 .../test-unprivileged-download-artifact.yml   | 26 +++++---
 .../unprivileged-download-artifact/action.yml | 59 +++++++++++++------
 4 files changed, 84 insertions(+), 27 deletions(-)
 create mode 100644 .github/workflows/issue-write-test.yaml

diff --git a/.github/workflows/issue-write-test.yaml b/.github/workflows/issue-write-test.yaml
new file mode 100644
index 0000000000000..9497e719e35b1
--- /dev/null
+++ b/.github/workflows/issue-write-test.yaml
@@ -0,0 +1,25 @@
+name: Test Issue Write Workflow
+
+permissions:
+  contents: read
+
+on:
+  pull_request:
+    paths:
+      - '.github/workflows/issue-write-test.yaml'
+
+jobs:
+  test-issue-write:
+    name: "Test Issue Write"
+    runs-on: ubuntu-24.04
+    if: github.repository == 'llvm/llvm-project'
+    steps:
+      - name: Write Comment
+        run: |
+          echo '[{"body": "This is a comment for testing the issue write workflow"}]' > comments
+      - name: Upload Comment
+        uses: actions/upload-artifact at 330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
+        with:
+          name: workflow-args
+          path: |
+            comments
diff --git a/.github/workflows/issue-write.yml b/.github/workflows/issue-write.yml
index ece6081ce9ba6..ac75dffd8b3b8 100644
--- a/.github/workflows/issue-write.yml
+++ b/.github/workflows/issue-write.yml
@@ -8,6 +8,7 @@ on:
       - "PR Request Release Note"
       - "Code lint"
       - "CI Checks"
+      - "Test Issue Write"
     types:
       - completed
 
diff --git a/.github/workflows/test-unprivileged-download-artifact.yml b/.github/workflows/test-unprivileged-download-artifact.yml
index 39ac3d57a3879..09f65f9a34061 100644
--- a/.github/workflows/test-unprivileged-download-artifact.yml
+++ b/.github/workflows/test-unprivileged-download-artifact.yml
@@ -21,15 +21,23 @@ jobs:
     if: github.repository_owner == 'llvm'
     runs-on: ubuntu-24.04
     steps:
-      - name: Create Test File
+      - name: Create Test Files
         run: |
-          echo "test" > comment
-      - name: Upload Test File
+          echo "foo" > comment1
+          echo "bar" > comment2
+      - name: Upload Test File 1
         uses: actions/upload-artifact at 330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
         with:
-          name: workflow-args
+          name: artifact-name-1
           path: |
-            comment
+            comment1
+      - name: Upload Test File 2
+        uses: actions/upload-artifact at 330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
+        with:
+          name: artifact-name-2
+          path: |
+            comment2
+        
 
   test-download:
     name: Test Unprivileged Download Artifact
@@ -47,8 +55,10 @@ jobs:
         id: download-artifact
         with:
           run-id: ${{ github.run_id }}
-          artifact-name: workflow-args
+          artifact-name: artifact-name-
       - name: Assert That Contents are the Same
         run: |
-          cat comment
-          [[ "$(cat comment)" == "test" ]]
+          cat comment1
+          [[ "$(cat comment1)" == "foo" ]]
+          cat comment2
+          [[ "$(cat comment2)" == "bar" ]]
diff --git a/.github/workflows/unprivileged-download-artifact/action.yml b/.github/workflows/unprivileged-download-artifact/action.yml
index 72815b26bcf41..173b8ca93252f 100644
--- a/.github/workflows/unprivileged-download-artifact/action.yml
+++ b/.github/workflows/unprivileged-download-artifact/action.yml
@@ -19,9 +19,9 @@ outputs:
       The filename of the downloaded artifact or the empty string if the
       artifact was not found.
     value: ${{ steps.download-artifact.outputs.filename }}
-  artifact-id:
+  artifact-ids:
     description: "The id of the artifact being downloaded."
-    value: ${{ steps.artifact-url.outputs.id }}
+    value: ${{ steps.artifact-url.outputs.ids }}
 
 
 runs:
@@ -36,46 +36,67 @@ runs:
             response = await github.rest.actions.listArtifactsForRepo({
               owner: context.repo.owner,
               repo: context.repo.repo,
-              name: "${{ inputs.artifact-name }}"
             })
           } else {
             response = await github.rest.actions.listWorkflowRunArtifacts({
               owner: context.repo.owner,
               repo: context.repo.repo,
               run_id: "${{ inputs.run-id }}",
-              name: "${{ inputs.artifact-name }}"
             })
           }
 
           console.log(response)
 
+          artifacts_to_download = []
           for (artifact of response.data.artifacts) {
+            if (artifact.name.startsWith("${{ inputs.artifact-name }}")) {
+              artifacts_to_download.push(artifact)
+            }
+          }
+
+          for (artifact of artifacts_to_download) {
             console.log(artifact);
           }
 
-          if (response.data.artifacts.length == 0) {
-            console.log("Could not find artifact ${{ inputs.artifact-name }} for workflow run ${{ inputs.run-id }}")
+          if (artifacts_to_download.length == 0) {
+            console.log("Could not find artifacts starting with name ${{ inputs.artifact-name }} for workflow run ${{ inputs.run-id }}")
             return;
           }
 
-          const url_response = await github.rest.actions.downloadArtifact({
-            owner: context.repo.owner,
-            repo: context.repo.repo,
-            artifact_id: response.data.artifacts[0].id,
-            archive_format: "zip"
-          })
+          artifact_ids = []
+          artifact_urls = []
+          artifact_names = []
+          for (artifact_to_download of artifacts_to_download) {
+            const url_response = await github.rest.actions.downloadArtifact({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              artifact_id: artifact_to_download.id,
+              archive_format: "zip"
+            })
+
+            artifact_ids.push(artifact_to_download.id)
+            artifact_urls.push('"' + url_response.url + '"')
+            artifact_names.push('"' + artifact_to_download.name + '"')
+          }
 
-          core.setOutput("url", url_response.url);
-          core.setOutput("id", response.data.artifacts[0].id);
+          core.setOutput("urls", artifact_urls.join(" "));
+          core.setOutput("ids", artifact_ids.join(" "));
+          core.setOutput("names", artifact_names.join(" "));
 
     - shell: bash
-      if: steps.artifact-url.outputs.url != ''
+      if: steps.artifact-url.outputs.urls != ''
       id: download-artifact
       run: |
-        curl -L -o ${{ inputs.artifact-name }}.zip "${{ steps.artifact-url.outputs.url }}"
-        echo "filename=${{ inputs.artifact-name }}.zip" >> $GITHUB_OUTPUT
+        artifact_urls=(${{ steps.artifact-url.outputs.urls }})
+        artifact_names=(${{ steps.artifact-url.outputs.names }})
+        for i in "${!artifact_urls[@]}"; do
+          curl -L -o "${artifact_names[$i]}.zip" "${artifact_urls[$i]}"
+        done
 
     - shell: bash
-      if: steps.download-artifact.outputs.filename != ''
+      if: steps.artifact-url.outputs.names != ''
       run: |
-        unzip ${{ steps.download-artifact.outputs.filename }}
+        artifact_names=(${{ steps.artifact-url.outputs.names }})
+        for name in "${artifact_names[@]}"; do
+          unzip "${name}.zip"
+        done



More information about the llvm-commits mailing list