This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new cd88aa4  (chores) ci: use a different download way because download 
action cannot download from a different workflow run
cd88aa4 is described below

commit cd88aa4804d9cdf1169e6299e6c6b73856d852b3
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Thu Mar 31 15:54:12 2022 +0200

    (chores) ci: use a different download way because download action cannot 
download from a different workflow run
---
 .github/workflows/component-pr.yaml | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/component-pr.yaml 
b/.github/workflows/component-pr.yaml
index 8a28c77..2cc5294 100644
--- a/.github/workflows/component-pr.yaml
+++ b/.github/workflows/component-pr.yaml
@@ -48,12 +48,32 @@ jobs:
               repo: context.repo.repo,
               body: `This PR changes components and will be tested 
automatically`
             })
-      - name: Download a single artifact
-        uses: actions/download-artifact@v3
+      - name: 'Download artifact'
+        uses: actions/[email protected]
         if: |
           github.event_name == 'workflow_run'
         with:
-          name: test-logs
+# Secure download based on 
https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
+          script: |
+            var artifacts = await github.actions.listWorkflowRunArtifacts({
+               owner: context.repo.owner,
+               repo: context.repo.repo,
+               run_id: ${{github.event.workflow_run.id }},
+            });
+            var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
+              return artifact.name == "test-logs"
+            })[0];
+            var download = await github.actions.downloadArtifact({
+               owner: context.repo.owner,
+               repo: context.repo.repo,
+               artifact_id: matchArtifact.id,
+               archive_format: 'zip',
+            });
+            var fs = require('fs');
+            fs.writeFileSync('${{github.workspace}}/test-logs.zip', 
Buffer.from(download.data));
+      - run: unzip test-logs.zip
+        if: |
+          github.event_name == 'workflow_run'
       - name: Get the test result
         if: |
           github.event_name == 'workflow_run'

Reply via email to