|
14 | 14 | permissions: |
15 | 15 | contents: write |
16 | 16 | steps: |
17 | | - - uses: actions/checkout@v4 |
| 17 | + - uses: runsascoded/gh-pnpm-dist@main |
18 | 18 | with: |
19 | | - ref: ${{ inputs.source_ref }} |
20 | | - fetch-depth: 0 |
21 | | - |
22 | | - - name: Get source commit SHA |
23 | | - id: source |
24 | | - run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
25 | | - |
26 | | - - uses: pnpm/action-setup@v4 |
27 | | - with: |
28 | | - version: 9 |
29 | | - |
30 | | - - uses: actions/setup-node@v4 |
31 | | - with: |
32 | | - node-version: '20' |
33 | | - cache: 'pnpm' |
34 | | - |
35 | | - - name: Install dependencies |
36 | | - run: pnpm install --frozen-lockfile |
37 | | - |
38 | | - - name: Build |
39 | | - run: pnpm run build |
40 | | - |
41 | | - - name: Checkout dist branch |
42 | | - run: | |
43 | | - if git fetch origin dist:dist 2>/dev/null; then |
44 | | - git checkout dist |
45 | | - else |
46 | | - git checkout --orphan dist |
47 | | - fi |
48 | | -
|
49 | | - - name: Configure git |
50 | | - run: | |
51 | | - git config user.name "github-actions[bot]" |
52 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
53 | | -
|
54 | | - - name: Commit built files |
55 | | - run: | |
56 | | - # Remove everything except dist/ |
57 | | - git rm -rf . 2>/dev/null || true |
58 | | - git clean -fdx -e dist -e node_modules |
59 | | -
|
60 | | - # Move dist contents to root |
61 | | - mv dist/* . 2>/dev/null || true |
62 | | - rmdir dist 2>/dev/null || true |
63 | | -
|
64 | | - # Add package.json and other metadata |
65 | | - git checkout ${{ steps.source.outputs.sha }} -- package.json README.md LICENSE 2>/dev/null || true |
66 | | -
|
67 | | - # Stage all changes |
68 | | - git add -A |
69 | | -
|
70 | | - # Create merge commit with two parents: |
71 | | - # 1. Previous dist commit (if exists) |
72 | | - # 2. Source commit from main |
73 | | - if git rev-parse --verify HEAD >/dev/null 2>&1; then |
74 | | - # dist branch exists, create merge commit |
75 | | - git commit -m "Build dist from ${{ steps.source.outputs.sha }}" || true |
76 | | - git merge --no-ff -m "Merge built dist from main@${{ steps.source.outputs.sha }}" ${{ steps.source.outputs.sha }} -s ours || true |
77 | | - else |
78 | | - # First dist commit |
79 | | - git commit -m "Initial dist build from ${{ steps.source.outputs.sha }}" |
80 | | - # Can't create merge commit for first commit |
81 | | - fi |
82 | | -
|
83 | | - - name: Push dist branch |
84 | | - run: git push origin dist --force-with-lease |
| 19 | + source_ref: ${{ inputs.source_ref }} |
0 commit comments