Add v2.0.0 branch to beta build workflow #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to Beta | |
| on: | |
| push: | |
| branches: | |
| - v2.0.0 | |
| workflow_dispatch: | |
| inputs: | |
| subfolder: | |
| description: 'Target subfolder in beta repo' | |
| required: true | |
| default: 'HTMLNotes' | |
| concurrency: | |
| group: "deploy-beta" | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-and-dispatch: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| artifact-url: ${{ steps.get-artifact.outputs.url }} | |
| steps: | |
| - name: Checkout source repo | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: updates | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install dependencies | |
| working-directory: Build | |
| run: npm i | |
| - name: Build | |
| working-directory: Build | |
| run: npm run build | |
| - name: Zip build artifacts | |
| run: zip -r htmlplayer-build.zip Build/dist | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: htmlplayer-build | |
| path: htmlplayer-build.zip | |
| retention-days: 1 | |
| - name: Get artifact download URL | |
| id: get-artifact | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: context.runId | |
| }); | |
| const artifact = artifacts.data.artifacts.find(a => a.name === 'htmlplayer-build'); | |
| if (!artifact) throw new Error('Artifact not found'); | |
| core.setOutput('url', artifact.archive_download_url); | |
| - name: Dispatch to beta repo | |
| run: | | |
| SUBFOLDER="${{ github.event.inputs.subfolder }}" | |
| ARTIFACT_URL="${{ steps.get-artifact.outputs.url }}" | |
| curl -X POST \ | |
| -H "Authorization: token ${{ secrets.BETA_PAT_TOKEN }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| https://api.github.com/repos/HTMLToolkit/beta/dispatches \ | |
| -d '{ | |
| "event_type": "deploy-build", | |
| "client_payload": { | |
| "source_repo": "'${{ github.repository }}'", | |
| "artifact_url": "'${ARTIFACT_URL}'", | |
| "token": "'${{ secrets.GITHUB_TOKEN }}'", | |
| "subfolder": "'${SUBFOLDER}'" | |
| } | |
| }' |