Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/issue-write-test.yaml
Original file line number Diff line number Diff line change
@@ -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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: workflow-args
path: |
comments
1 change: 1 addition & 0 deletions .github/workflows/issue-write.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- "PR Request Release Note"
- "Code lint"
- "CI Checks"
- "Test Issue Write"
types:
- completed

Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/test-unprivileged-download-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: workflow-args
name: artifact-name-1
path: |
comment
comment1
- name: Upload Test File 2
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: artifact-name-2
path: |
comment2


test-download:
name: Test Unprivileged Download Artifact
Expand All @@ -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" ]]
59 changes: 40 additions & 19 deletions .github/workflows/unprivileged-download-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Loading