Skip to content

Commit

Permalink
Multi-file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
PathogenDavid committed Dec 19, 2020
1 parent 00fd784 commit dbde5ab
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions .github/workflows/release-event-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,43 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create test file
run: echo "Hello, world! ${{github.event.release.name}}" > test.txt
run: |
echo "Hello, world! ${{github.event.release.name}}" > test.txt
echo "The other file! ${{github.event.release.name}}" > test2.txt
- name: Upload test file
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{github.event.release.upload_url}}
asset_path: ./test.txt
asset_name: test.txt
asset_content_type: text/plain
asset_name: test-uploadaction.txt
asset_content_type: text/plain
- name: Upload test files
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
user-agent: actions/github-script for ${{github.repository}}
script: |
const fs = require('fs').promises;
const path = require('path');
for (let filePath of await fs.readdir('.')) {
const fileExtension = path.extname(filePath);
if (fileExtension != '.txt') {
continue;
}
console.log(`Uploading '${filePath}'`);
const contentLength = (await fs.stat(filePath)).size;
const fileContents = await fs.readFile(filePath);
await github.repos.uploadReleaseAsset({
url: '${{github.event.release.upload_url}}',
headers: {
'content-type': 'application/octet-stream',
'content-length': contentLength
},
name: path.basename(filePath),
file: fileContents
});
}

0 comments on commit dbde5ab

Please sign in to comment.