diff --git a/.github/workflows/astro.yml b/.github/workflows/astro.yml index ec9fffe..555c001 100644 --- a/.github/workflows/astro.yml +++ b/.github/workflows/astro.yml @@ -6,8 +6,11 @@ name: Deploy Astro site to Pages on: # Runs on pushes targeting the default branch - push: - branches: ["master"] + # push: + # branches: ["master"] + # Runs on creating a release + release: + types: [published] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -56,7 +59,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: "18" + node-version: "18.x" cache: ${{ steps.detect-package-manager.outputs.manager }} cache-dependency-path: ${{ env.BUILD_PATH }}/package-lock.json - name: Setup Pages diff --git a/.github/workflows/npm-publish-on-release.yml b/.github/workflows/npm-publish-on-release.yml new file mode 100644 index 0000000..5c3ae7e --- /dev/null +++ b/.github/workflows/npm-publish-on-release.yml @@ -0,0 +1,23 @@ +name: On creating a release, publish package to npm +on: + # Runs on creating a release + release: + types: [published] +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v3 + # Setup .npmrc file to publish to GitHub Packages + - uses: actions/setup-node@v3 + with: + node-version: "18.x" + registry-url: "https://registry.npmjs.org" + - run: npm ci + - run: npm run build + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}