|
| 1 | +# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ for an example using this strategy |
| 2 | +name: Auto Publish Release |
| 3 | +on: |
| 4 | +workflow_run: |
| 5 | + workflows: ["Draft Release"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + |
| 9 | +jobs: |
| 10 | + publish_release: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + if: > |
| 13 | + ${{ github.event.workflow_run.conclusion == 'success' }} |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v2 |
| 17 | + - name: Install Python |
| 18 | + uses: actions/setup-python@v2 |
| 19 | + with: |
| 20 | + python-version: 3.9 |
| 21 | + architecture: "x64" |
| 22 | + - name: Install node |
| 23 | + uses: actions/setup-node@v2 |
| 24 | + with: |
| 25 | + node-version: "14.x" |
| 26 | + - name: Upgrade packaging dependencies |
| 27 | + run: | |
| 28 | + pip install --upgrade pip setuptools wheel --user |
| 29 | +
|
| 30 | + - name: Download Draft Release URL artifact |
| 31 | + |
| 32 | + with: |
| 33 | + script: | |
| 34 | + var artifacts = await github.actions.listWorkflowRunArtifacts({ |
| 35 | + owner: context.repo.owner, |
| 36 | + repo: context.repo.repo, |
| 37 | + run_id: ${{github.event.workflow_run.id }}, |
| 38 | + }); |
| 39 | + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { |
| 40 | + return artifact.name == "draft-release-url" |
| 41 | + })[0]; |
| 42 | + var download = await github.actions.downloadArtifact({ |
| 43 | + owner: context.repo.owner, |
| 44 | + repo: context.repo.repo, |
| 45 | + artifact_id: matchArtifact.id, |
| 46 | + archive_format: 'zip', |
| 47 | + }); |
| 48 | + var fs = require('fs'); |
| 49 | + fs.writeFileSync('${{github.workspace}}/url.zip', Buffer.from(download.data)); |
| 50 | +
|
| 51 | + - name: Extract Draft Release URL |
| 52 | + id: draft-release-url |
| 53 | + run: | |
| 54 | + unzip url.zip |
| 55 | + echo "::set-output name=url::$(cat draft-release-url.txt)" |
| 56 | +
|
| 57 | + - name: Publish Release |
| 58 | + id: publish-release |
| 59 | + if: ${{ steps.draft-release-url.outputs.url !== "" }} |
| 60 | + env: |
| 61 | + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |
| 62 | + PYPI_TOKEN_MAP: ${{ secrets.PYPI_TOKEN_MAP }} |
| 63 | + TWINE_USERNAME: __token__ |
| 64 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 65 | + uses: jupyter-server/jupyter_releaser/.github/actions/publish-release@v1 |
| 66 | + with: |
| 67 | + token: ${{ secrets.ADMIN_GITHUB_TOKEN }} |
| 68 | + release_url: ${{ steps.draft-release-url.outputs.url }} |
| 69 | + |
| 70 | + - name: "** Next Step **" |
| 71 | + run: | |
| 72 | + if [ ${{ steps.draft-release-url.outputs.url }} ];then |
| 73 | + echo "Verify the final release" |
| 74 | + echo ${{ steps.publish-release.outputs.release_url }} |
| 75 | + if [ ! -z "${{ steps.publish-release.outputs.pr_url }}" ]; then |
| 76 | + echo "Merge the forwardport PR" |
| 77 | + echo ${{ steps.publish-release.outputs.pr_url }} |
| 78 | + fi |
| 79 | + else |
| 80 | + echo "No Action Needed, Skipped Auto Publish" |
| 81 | + fi |
0 commit comments