diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..134494f --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,40 @@ +name: Publish Preview Packages + +on: + pull_request_review: + types: [submitted] + +permissions: {} + +jobs: + check: + if: github.event.review.state == 'approved' + runs-on: ubuntu-latest + outputs: + has-permissions: ${{ steps.checkPermissions.outputs.require-result }} + steps: + - name: Check permissions + id: checkPermissions + uses: actions-cool/check-user-permission@v2 + with: + require: "write" + + publish: + needs: check + if: needs.check.outputs.has-permissions == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # Check out the reviewed commit, not the latest PR head, to prevent + # publishing code that was pushed after approval. + ref: ${{ github.event.pull_request.head.sha }} + + - uses: actions/setup-node@v4 + with: + node-version: "20.x" + + - run: npm ci + - run: npx vite build + - run: npx pkg-pr-new publish