pnpm workspace root for Barazo forum development — shared configuration, tooling, and cross-package dependency management
barazo.forum
1name: Sync Lockfile
2
3on:
4 repository_dispatch:
5 types: [sync-lockfile]
6 schedule:
7 # Hourly fallback -- catches Dependabot merges and edge cases
8 - cron: "0 * * * *"
9 workflow_dispatch: {}
10
11permissions:
12 contents: write
13 pull-requests: write
14
15jobs:
16 sync:
17 name: Regenerate workspace lockfile
18 runs-on: ubuntu-latest
19 steps:
20 # ------------------------------------------------------------------
21 # Determine deploy refs from dispatch payload, or default to main
22 # ------------------------------------------------------------------
23 - name: Determine deploy refs
24 id: refs
25 run: |
26 if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
27 echo "trigger=${{ github.event.client_payload.trigger_repo || 'barazo-workspace' }}" >> "$GITHUB_OUTPUT"
28 echo "api_ref=${{ github.event.client_payload.api_ref || 'main' }}" >> "$GITHUB_OUTPUT"
29 echo "web_ref=${{ github.event.client_payload.web_ref || 'main' }}" >> "$GITHUB_OUTPUT"
30 echo "deploy=true" >> "$GITHUB_OUTPUT"
31 else
32 echo "trigger=${{ github.event_name }}" >> "$GITHUB_OUTPUT"
33 echo "api_ref=main" >> "$GITHUB_OUTPUT"
34 echo "web_ref=main" >> "$GITHUB_OUTPUT"
35 echo "deploy=false" >> "$GITHUB_OUTPUT"
36 fi
37
38 # ------------------------------------------------------------------
39 # Regenerate the workspace lockfile
40 # ------------------------------------------------------------------
41 - name: Checkout workspace
42 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
43
44 - name: Setup pnpm
45 uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
46
47 - name: Setup Node.js
48 uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
49 with:
50 node-version: 24
51
52 - name: Fetch workspace member manifests
53 run: |
54 for pkg in barazo-api barazo-web barazo-lexicons barazo-plugins; do
55 mkdir -p "$pkg"
56 curl -sfL "https://raw.githubusercontent.com/singi-labs/$pkg/main/package.json" \
57 -o "$pkg/package.json"
58 done
59 # Fetch sub-packages for plugins monorepo
60 mkdir -p barazo-plugins/packages/plugin-signatures
61 curl -sfL "https://raw.githubusercontent.com/singi-labs/barazo-plugins/main/packages/plugin-signatures/package.json" \
62 -o "barazo-plugins/packages/plugin-signatures/package.json"
63
64 - name: Regenerate lockfile
65 run: pnpm install --no-frozen-lockfile
66
67 - name: Check for lockfile changes
68 id: diff
69 run: |
70 if git diff --quiet pnpm-lock.yaml; then
71 echo "changed=false" >> "$GITHUB_OUTPUT"
72 echo "Lockfile is already up to date."
73 else
74 echo "changed=true" >> "$GITHUB_OUTPUT"
75 echo "Lockfile has changed -- needs update."
76 git diff --stat pnpm-lock.yaml
77 fi
78
79 # ------------------------------------------------------------------
80 # Create a PR for lockfile changes, then auto-merge it.
81 # Direct pushes to main are blocked by branch protection, so we
82 # go through a PR instead. The squash-merge to main triggers
83 # deploy-staging.yml automatically (it watches lockfile paths).
84 # ------------------------------------------------------------------
85 - name: Create lockfile PR
86 if: steps.diff.outputs.changed == 'true'
87 id: pr
88 uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11
89 with:
90 commit-message: "fix(deps): auto-sync lockfile with sub-repo dependencies"
91 branch: auto/sync-lockfile
92 delete-branch: true
93 title: "fix(deps): auto-sync lockfile with sub-repo dependencies"
94 body: |
95 Automated lockfile regeneration.
96
97 Triggered by: `${{ steps.refs.outputs.trigger }}`
98
99 - name: Auto-merge lockfile PR
100 if: steps.diff.outputs.changed == 'true' && steps.pr.outputs.pull-request-number
101 env:
102 GH_TOKEN: ${{ secrets.DEPLOY_PAT }}
103 run: |
104 gh pr merge ${{ steps.pr.outputs.pull-request-number }} \
105 --repo singi-labs/barazo-workspace \
106 --squash \
107 --auto
108
109 # ------------------------------------------------------------------
110 # Trigger staging deploy directly ONLY when a sub-repo dispatched
111 # this workflow but the lockfile did not change. When the lockfile
112 # does change, the PR merge to main triggers deploy-staging.yml
113 # automatically, so we skip here to avoid a duplicate deploy.
114 # ------------------------------------------------------------------
115 - name: Trigger staging deploy
116 if: steps.refs.outputs.deploy == 'true' && steps.diff.outputs.changed == 'false'
117 uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
118 with:
119 token: ${{ secrets.DEPLOY_PAT }}
120 repository: singi-labs/barazo-deploy
121 event-type: deploy-staging
122 client-payload: |
123 {
124 "trigger_repo": "${{ steps.refs.outputs.trigger }}",
125 "api_ref": "${{ steps.refs.outputs.api_ref }}",
126 "web_ref": "${{ steps.refs.outputs.web_ref }}"
127 }