Deploy to Godot #11
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 npm | |
| on: | |
| issues: | |
| types: [opened, labeled] | |
| jobs: | |
| deploy: | |
| name: Release to npm | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event.issue.title == 'Deploy to npm' && | |
| contains(github.event.issue.labels.*.name, 'CI') | |
| permissions: | |
| contents: write | |
| issues: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Validate release secrets | |
| run: | | |
| required=( | |
| NPM_TOKEN | |
| ) | |
| for name in "${required[@]}"; do | |
| if [ -z "${!name}" ]; then | |
| echo "ERROR: Missing required secret: $name" | |
| exit 1 | |
| fi | |
| done | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Install dependencies | |
| working-directory: js-ts | |
| run: npm ci | |
| - name: Build and publish to npm | |
| working-directory: js-ts | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Comment on issue with result | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const success = '${{ job.status }}' === 'success'; | |
| const body = success | |
| ? `Deployment succeeded. \`qti-neon\` has been published to npm.` | |
| : `Deployment failed. Check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.`; | |
| github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body | |
| }); |