|
| 1 | +name: Release SwaggerUI Dist |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Release SwaggerUI"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + branches: [ master ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + release-swagger-ui-dist: |
| 12 | + if: github.event.workflow_run.conclusion == 'success' |
| 13 | + name: Release swagger-ui-dist npm package |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + persist-credentials: false |
| 21 | + ref: master |
| 22 | + |
| 23 | + - name: Setup Node.js |
| 24 | + uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: 22 |
| 27 | + cache: npm |
| 28 | + cache-dependency-path: package-lock.json |
| 29 | + |
| 30 | + - name: Install dependencies |
| 31 | + run: npm ci |
| 32 | + |
| 33 | + - name: Download build artifact |
| 34 | + uses: actions/github-script@v7 |
| 35 | + with: |
| 36 | + script: | |
| 37 | + const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
| 38 | + owner: context.repo.owner, |
| 39 | + repo: context.repo.repo, |
| 40 | + run_id: context.payload.workflow_run.id, |
| 41 | + }); |
| 42 | + const matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { |
| 43 | + return artifact.name == "dist" |
| 44 | + })[0]; |
| 45 | + const download = await github.rest.actions.downloadArtifact({ |
| 46 | + owner: context.repo.owner, |
| 47 | + repo: context.repo.repo, |
| 48 | + artifact_id: matchArtifact.id, |
| 49 | + archive_format: 'zip', |
| 50 | + }); |
| 51 | + const fs = require('fs'); |
| 52 | + fs.writeFileSync('${{github.workspace}}/dist.zip', Buffer.from(download.data)); |
| 53 | + - run: | |
| 54 | + unzip -o dist.zip -d dist |
| 55 | +
|
| 56 | + - name: Publish to npmjs.com |
| 57 | + run: ./deploy.sh |
| 58 | + working-directory: ./swagger-ui-dist-package |
| 59 | + env: |
| 60 | + NPM_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }} |
| 61 | + PUBLISH_DIST: true |
0 commit comments