|
6 | 6 | # -- Oh! |
7 | 7 | # > Note: The release event is not triggered for draft releases. |
8 | 8 | # Emphasis on ****release event****, I read this as meaning to be the "released" type. |
| 9 | + # `created` will fire if you create a release and publish immediately without making it a draft first. |
9 | 10 | ##################### |
10 | 11 | # Edited works! |
11 | 12 | # Not sure how to trigger unpublished... |
12 | 13 | # Deleted works |
13 | | - # Not sure what prereleased/released are either (I would think they describe what I'd call "publish", but that's obviously a separate event) |
14 | | - types: [published, unpublished, created, edited, deleted, prereleased, released] |
| 14 | + # `released` (and probably `prereleased`) seem to only happen if you publish immediately without making a draft first. |
| 15 | + #types: [published, unpublished, created, edited, deleted, prereleased, released] |
| 16 | + types: [published] |
15 | 17 | jobs: |
16 | 18 | do-release: |
17 | 19 | runs-on: ubuntu-latest |
|
29 | 31 | if: github.event.action == 'published' |
30 | 32 | runs-on: ubuntu-latest |
31 | 33 | steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v2 |
32 | 36 | - name: Test getting the release URL in a GitHub script |
33 | 37 | uses: actions/github-script@v3 |
34 | 38 | with: |
|
48 | 52 | asset_name: test-uploadaction.txt |
49 | 53 | asset_content_type: text/plain |
50 | 54 | - name: Upload test files |
51 | | - uses: actions/github-script@v3 |
| 55 | + uses: actions/github-script@v4 |
52 | 56 | with: |
53 | 57 | #github-token: ${{secrets.GITHUB_TOKEN}} |
54 | 58 | user-agent: actions/github-script for ${{github.repository}} |
55 | | - script: | |
56 | | - const fs = require('fs').promises; |
57 | | - const path = require('path'); |
58 | | -
|
59 | | - for (let filePath of await fs.readdir('.')) { |
60 | | - const fileExtension = path.extname(filePath); |
61 | | - if (fileExtension != '.txt') { |
62 | | - continue; |
63 | | - } |
64 | | -
|
65 | | - console.log(`Uploading '${filePath}'`); |
66 | | - const contentLength = (await fs.stat(filePath)).size; |
67 | | - const fileContents = await fs.readFile(filePath); |
68 | | - await github.repos.uploadReleaseAsset({ |
69 | | - url: '${{github.event.release.upload_url}}', |
70 | | - headers: { |
71 | | - 'content-type': 'application/octet-stream', |
72 | | - 'content-length': contentLength |
73 | | - }, |
74 | | - name: path.basename(filePath), |
75 | | - data: fileContents |
76 | | - }); |
77 | | - } |
| 59 | + script: await require('./.github/workflows/upload-release-assets.js')(github, context); |
0 commit comments