|
| 1 | +name: Deploy to Beta |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - updates |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + subfolder: |
| 10 | + description: 'Target subfolder in beta repo' |
| 11 | + required: true |
| 12 | + default: 'HTMLNotes' |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: "deploy-beta" |
| 16 | + cancel-in-progress: false |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-and-dispatch: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + outputs: |
| 25 | + artifact-url: ${{ steps.get-artifact.outputs.url }} |
| 26 | + steps: |
| 27 | + - name: Checkout source repo |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + ref: updates |
| 31 | + |
| 32 | + - name: Use Node.js |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: "20" |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + working-directory: Build |
| 39 | + run: npm i |
| 40 | + |
| 41 | + - name: Build |
| 42 | + working-directory: Build |
| 43 | + run: npm run build |
| 44 | + |
| 45 | + - name: Zip build artifacts |
| 46 | + run: zip -r htmlplayer-build.zip Build/dist |
| 47 | + |
| 48 | + - name: Upload artifact |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: htmlplayer-build |
| 52 | + path: htmlplayer-build.zip |
| 53 | + retention-days: 1 |
| 54 | + |
| 55 | + - name: Get artifact download URL |
| 56 | + id: get-artifact |
| 57 | + uses: actions/github-script@v7 |
| 58 | + with: |
| 59 | + script: | |
| 60 | + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
| 61 | + owner: context.repo.owner, |
| 62 | + repo: context.repo.repo, |
| 63 | + run_id: context.runId |
| 64 | + }); |
| 65 | + const artifact = artifacts.data.artifacts.find(a => a.name === 'htmlplayer-build'); |
| 66 | + if (!artifact) throw new Error('Artifact not found'); |
| 67 | + core.setOutput('url', artifact.archive_download_url); |
| 68 | +
|
| 69 | + - name: Dispatch to beta repo |
| 70 | + run: | |
| 71 | + SUBFOLDER="${{ github.event.inputs.subfolder }}" |
| 72 | + ARTIFACT_URL="${{ steps.get-artifact.outputs.url }}" |
| 73 | + curl -X POST \ |
| 74 | + -H "Authorization: token ${{ secrets.BETA_PAT_TOKEN }}" \ |
| 75 | + -H "Accept: application/vnd.github+json" \ |
| 76 | + https://api.github.com/repos/HTMLToolkit/beta/dispatches \ |
| 77 | + -d '{ |
| 78 | + "event_type": "deploy-build", |
| 79 | + "client_payload": { |
| 80 | + "source_repo": "'${{ github.repository }}'", |
| 81 | + "artifact_url": "'${ARTIFACT_URL}'", |
| 82 | + "token": "'${{ secrets.GITHUB_TOKEN }}'", |
| 83 | + "subfolder": "'${SUBFOLDER}'" |
| 84 | + } |
| 85 | + }' |
0 commit comments