Skip to content

Commit 37df945

Browse files
committed
🔧 feat: improve publish workflow with concurrency control and fork protection
1 parent d78f47d commit 37df945

1 file changed

Lines changed: 11 additions & 20 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
name: 🚀 Publish to NPM
1+
name: 🚀 Release
22

33
on:
44
push:
55
branches: [master]
6-
pull_request:
7-
branches: [master]
86

9-
# Add permissions for the workflow
10-
permissions:
11-
contents: write
12-
packages: write
13-
issues: write
14-
pull-requests: write
15-
id-token: write
7+
concurrency: ${{ github.workflow }}-${{ github.ref }}
8+
9+
permissions: {} # reset
1610

1711
jobs:
1812
test:
@@ -44,18 +38,19 @@ jobs:
4438
run: echo "✅ All quality checks passed"
4539

4640
release:
47-
name: 🚀 Release with Changesets
41+
# IMPORTANT: prevent this action from running on forks
42+
if: github.repository == 'MarcelOlsen/mini-react'
43+
permissions:
44+
contents: write # to create release (changesets/action)
45+
pull-requests: write # to create pull request (changesets/action)
46+
name: 🚀 Release
4847
needs: test
4948
runs-on: ubuntu-latest
50-
# Only run on pushes to master
51-
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
5249
steps:
5350
- name: 📥 Checkout code
5451
uses: actions/checkout@v4
5552
with:
5653
fetch-depth: 0
57-
# Use PAT for creating PRs if available, fallback to GITHUB_TOKEN
58-
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
5954

6055
- name: 🟢 Setup Bun
6156
uses: oven-sh/setup-bun@v1
@@ -73,10 +68,6 @@ jobs:
7368
uses: changesets/action@v1
7469
with:
7570
publish: bunx changeset publish
76-
version: bunx changeset version && bun run check:write
77-
commit: "chore: release package"
78-
title: "chore: release package"
7971
env:
80-
# Use PAT for creating PRs if available, fallback to GITHUB_TOKEN
81-
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8273
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)