-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support direct file uploads #764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
9c47937
e785baf
c6ec997
4177a10
6b68470
ffeab76
15af323
428074b
bdabba3
3a2b6d4
518025b
d5c7bee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -94,7 +94,7 @@ | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Download Artifact #1 and verify the correctness of the content | ||||||||||||||||||||||||||||||||
| - name: 'Download artifact #1' | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@main | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: 'Artifact-A-${{ matrix.runs-on }}' | ||||||||||||||||||||||||||||||||
| path: some/new/path | ||||||||||||||||||||||||||||||||
|
|
@@ -114,7 +114,7 @@ | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Download Artifact #2 and verify the correctness of the content | ||||||||||||||||||||||||||||||||
| - name: 'Download artifact #2' | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@main | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: 'Artifact-Wildcard-${{ matrix.runs-on }}' | ||||||||||||||||||||||||||||||||
| path: some/other/path | ||||||||||||||||||||||||||||||||
|
|
@@ -135,7 +135,7 @@ | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Download Artifact #4 and verify the correctness of the content | ||||||||||||||||||||||||||||||||
| - name: 'Download artifact #4' | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@main | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: 'Multi-Path-Artifact-${{ matrix.runs-on }}' | ||||||||||||||||||||||||||||||||
| path: multi/artifact | ||||||||||||||||||||||||||||||||
|
|
@@ -155,7 +155,7 @@ | |||||||||||||||||||||||||||||||
| shell: pwsh | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: 'Download symlinked artifact' | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@main | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: 'Symlinked-Artifact-${{ matrix.runs-on }}' | ||||||||||||||||||||||||||||||||
| path: from/symlink | ||||||||||||||||||||||||||||||||
|
|
@@ -196,7 +196,7 @@ | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Download replaced Artifact #1 and verify the correctness of the content | ||||||||||||||||||||||||||||||||
| - name: 'Download artifact #1 again' | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@main | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: 'Artifact-A-${{ matrix.runs-on }}' | ||||||||||||||||||||||||||||||||
| path: overwrite/some/new/path | ||||||||||||||||||||||||||||||||
|
|
@@ -213,7 +213,102 @@ | |||||||||||||||||||||||||||||||
| Write-Error "File contents of downloaded artifact are incorrect" | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| shell: pwsh | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Upload a single file without archiving (direct file upload) | ||||||||||||||||||||||||||||||||
| - name: 'Create direct upload file' | ||||||||||||||||||||||||||||||||
| run: echo -n 'direct file upload content' > direct-upload-${{ matrix.runs-on }}.txt | ||||||||||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: 'Upload direct file artifact' | ||||||||||||||||||||||||||||||||
| uses: ./ | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: 'Direct-File-${{ matrix.runs-on }}' | ||||||||||||||||||||||||||||||||
| path: direct-upload-${{ matrix.runs-on }}.txt | ||||||||||||||||||||||||||||||||
| archive: false | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: 'Download direct file artifact' | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@main | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: direct-upload-${{ matrix.runs-on }}.txt | ||||||||||||||||||||||||||||||||
| path: direct-download | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: 'Verify direct file artifact' | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| $file = "direct-download/direct-upload-${{ matrix.runs-on }}.txt" | ||||||||||||||||||||||||||||||||
| if(!(Test-Path -path $file)) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| Write-Error "Expected file does not exist" | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| if(!((Get-Content $file -Raw).TrimEnd() -ceq "direct file upload content")) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| Write-Error "File contents of downloaded artifact are incorrect" | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| shell: pwsh | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| upload-html-report: | ||||||||||||||||||||||||||||||||
| name: Upload HTML Report | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Setup Node 24 | ||||||||||||||||||||||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| node-version: 24.x | ||||||||||||||||||||||||||||||||
| cache: 'npm' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||||
| run: npm ci | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Compile | ||||||||||||||||||||||||||||||||
| run: npm run build | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Create HTML report | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| cat > report.html << 'EOF' | ||||||||||||||||||||||||||||||||
| <!DOCTYPE html> | ||||||||||||||||||||||||||||||||
| <html lang="en"> | ||||||||||||||||||||||||||||||||
| <head> | ||||||||||||||||||||||||||||||||
| <meta charset="UTF-8"> | ||||||||||||||||||||||||||||||||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||||||||||||||||||||||||||||||
| <title>Artifact Upload Test Report</title> | ||||||||||||||||||||||||||||||||
| <style> | ||||||||||||||||||||||||||||||||
| body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; max-width: 800px; margin: 40px auto; padding: 0 20px; color: #24292f; } | ||||||||||||||||||||||||||||||||
| h1 { border-bottom: 1px solid #d0d7de; padding-bottom: 8px; } | ||||||||||||||||||||||||||||||||
| .success { color: #1a7f37; } | ||||||||||||||||||||||||||||||||
| .info { background: #ddf4ff; border: 1px solid #54aeff; border-radius: 6px; padding: 12px 16px; margin: 16px 0; } | ||||||||||||||||||||||||||||||||
| table { border-collapse: collapse; width: 100%; margin: 16px 0; } | ||||||||||||||||||||||||||||||||
| th, td { border: 1px solid #d0d7de; padding: 8px 12px; text-align: left; } | ||||||||||||||||||||||||||||||||
| th { background: #f6f8fa; } | ||||||||||||||||||||||||||||||||
| </style> | ||||||||||||||||||||||||||||||||
| </head> | ||||||||||||||||||||||||||||||||
| <body> | ||||||||||||||||||||||||||||||||
| <h1>Artifact Upload Test Report</h1> | ||||||||||||||||||||||||||||||||
| <div class="info"> | ||||||||||||||||||||||||||||||||
| <strong>This HTML file was uploaded as a single un-zipped artifact.</strong> | ||||||||||||||||||||||||||||||||
| If you can see this in the browser, the feature is working correctly! | ||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||
| <table> | ||||||||||||||||||||||||||||||||
| <tr><th>Property</th><th>Value</th></tr> | ||||||||||||||||||||||||||||||||
| <tr><td>Upload method</td><td><code>archive: false</code></td></tr> | ||||||||||||||||||||||||||||||||
| <tr><td>Content-Type</td><td><code>text/html</code></td></tr> | ||||||||||||||||||||||||||||||||
| <tr><td>File</td><td><code>report.html</code></td></tr> | ||||||||||||||||||||||||||||||||
| </table> | ||||||||||||||||||||||||||||||||
| <p class="success">✔ Single file upload is working!</p> | ||||||||||||||||||||||||||||||||
| </body> | ||||||||||||||||||||||||||||||||
| </html> | ||||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Upload HTML report (no archive) | ||||||||||||||||||||||||||||||||
| uses: ./ | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: 'test-report' | ||||||||||||||||||||||||||||||||
| path: report.html | ||||||||||||||||||||||||||||||||
| archive: false | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| merge: | ||||||||||||||||||||||||||||||||
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium test
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
|
||||||||||||||||||||||||||||||||
| name: Merge | ||||||||||||||||||||||||||||||||
| needs: build | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
@@ -230,7 +325,7 @@ | |||||||||||||||||||||||||||||||
| # easier to identify each of the merged artifacts | ||||||||||||||||||||||||||||||||
| separate-directories: true | ||||||||||||||||||||||||||||||||
| - name: 'Download merged artifacts' | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@main | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: merged-artifacts | ||||||||||||||||||||||||||||||||
| path: all-merged-artifacts | ||||||||||||||||||||||||||||||||
|
|
@@ -266,7 +361,7 @@ | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Download merged artifacts and verify the correctness of the content | ||||||||||||||||||||||||||||||||
| - name: 'Download merged artifacts' | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@main | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: Merged-Artifact-As | ||||||||||||||||||||||||||||||||
| path: merged-artifact-a | ||||||||||||||||||||||||||||||||
|
|
@@ -290,3 +385,44 @@ | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| shell: pwsh | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| cleanup: | ||||||||||||||||||||||||||||||||
| name: Cleanup Artifacts | ||||||||||||||||||||||||||||||||
| needs: [build, merge] | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Setup Node 24 | ||||||||||||||||||||||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| node-version: 24.x | ||||||||||||||||||||||||||||||||
| cache: 'npm' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||||
| run: npm ci | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Delete test artifacts | ||||||||||||||||||||||||||||||||
| uses: actions/github-script@v7 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| script: | | ||||||||||||||||||||||||||||||||
| const artifactClient = require('@actions/artifact'); | ||||||||||||||||||||||||||||||||
| const artifact = artifactClient.default || artifactClient; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| const {artifacts} = await artifact.listArtifacts({latest: true}); | ||||||||||||||||||||||||||||||||
| const keep = ['report.html']; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| for (const a of artifacts) { | ||||||||||||||||||||||||||||||||
| if (keep.includes(a.name)) { | ||||||||||||||||||||||||||||||||
| console.log(`Keeping artifact '${a.name}'`); | ||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| await artifact.deleteArtifact(a.name); | ||||||||||||||||||||||||||||||||
| console.log(`Deleted artifact '${a.name}'`); | ||||||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||||||
| console.log(`Could not delete artifact '${a.name}': ${err.message}`); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium test
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 4 months ago In general, the fix is to add an explicit The permissions:
actions: write
contents: read
Suggested changeset
1
.github/workflows/test.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Refresh and try again.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set the permissions block. |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Genuinely curious - why isn't this action pinned to its commit SHA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two actions are intertwined quite a bit. Keeping this test's reference relative helps smoke test
somewhat.