Skip to content

Commit 886333d

Browse files
authored
Merge pull request #84 from objectstack-ai/copilot/add-auto-merge-configuration
2 parents 0597d06 + da32d41 commit 886333d

File tree

5 files changed

+98
-2
lines changed

5 files changed

+98
-2
lines changed

.github/WORKFLOWS.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,67 @@ Add these badges to show workflow status:
338338
3. Update documentation
339339
4. Monitor first few runs after changes
340340

341+
## Automatic Lockfile Merge Resolution
342+
343+
### Overview
344+
345+
The repository is configured to automatically resolve merge conflicts in `pnpm-lock.yaml` using a custom Git merge driver. This prevents manual intervention when lockfile conflicts occur during branch merges or automated workflows.
346+
347+
### How It Works
348+
349+
**Repository Configuration** (`.gitattributes`):
350+
```
351+
pnpm-lock.yaml merge=pnpm-merge
352+
```
353+
354+
This tells Git to use the `pnpm-merge` driver when merging `pnpm-lock.yaml` files.
355+
356+
**Workflow Configuration** (Applied in CI workflows):
357+
```yaml
358+
- name: Configure Git merge driver for pnpm-lock.yaml
359+
run: |
360+
# Configure custom merge driver for pnpm-lock.yaml
361+
# This allows Git to automatically resolve lockfile conflicts by regenerating it
362+
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
363+
git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"
364+
```
365+
366+
### When It's Used
367+
368+
This configuration is active in the following workflows:
369+
- **Changeset Release** (`changeset-release.yml`): Handles lockfile updates during version bumping
370+
- **Auto Changelog** (`changelog.yml`): Prevents conflicts during automated changelog updates
371+
372+
### Adding to New Workflows
373+
374+
If you create a workflow that performs git merge operations or might encounter lockfile conflicts, add the configuration step **after checkout** and **before any merge operation**:
375+
376+
```yaml
377+
steps:
378+
- name: Checkout code
379+
uses: actions/checkout@v4
380+
with:
381+
fetch-depth: 0
382+
383+
- name: Configure Git merge driver for pnpm-lock.yaml
384+
run: |
385+
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
386+
git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"
387+
388+
# ... rest of your workflow steps including merge operations
389+
```
390+
391+
### Benefits
392+
393+
- **Fully Automated**: No manual intervention needed for lockfile conflicts
394+
- **Clean Repository**: Configuration is temporary (CI-only), doesn't modify repository files
395+
- **Reliable**: Uses pnpm's built-in dependency resolution to regenerate lockfiles
396+
- **Consistent**: Ensures lockfiles are always in sync with package.json changes
397+
398+
### Local Development
399+
400+
For local development, contributors can configure the same merge driver by following the instructions in [CONTRIBUTING.md](../CONTRIBUTING.md).
401+
341402
## Future Enhancements
342403

343404
Potential workflow additions:

.github/workflows/changelog.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ jobs:
1818
with:
1919
fetch-depth: 0
2020

21+
- name: Configure Git merge driver for pnpm-lock.yaml
22+
run: |
23+
# Configure custom merge driver for pnpm-lock.yaml
24+
# This allows Git to automatically resolve lockfile conflicts by regenerating it
25+
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
26+
git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"
27+
2128
- name: Generate changelog
2229
uses: orhun/git-cliff-action@v4
2330
id: changelog

.github/workflows/changeset-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup pnpm
2626
uses: pnpm/action-setup@v4
2727
with:
28-
version: 9
28+
version: 10
2929

3030
- name: Setup Node.js
3131
uses: actions/setup-node@v4

.github/workflows/changeset-release.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup pnpm
2626
uses: pnpm/action-setup@v4
2727
with:
28-
version: 9
28+
version: 10
2929

3030
- name: Setup Node.js
3131
uses: actions/setup-node@v4
@@ -34,6 +34,13 @@ jobs:
3434
cache: 'pnpm'
3535
registry-url: 'https://registry.npmjs.org'
3636

37+
- name: Configure Git merge driver for pnpm-lock.yaml
38+
run: |
39+
# Configure custom merge driver for pnpm-lock.yaml
40+
# This allows Git to automatically resolve lockfile conflicts by regenerating it
41+
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
42+
git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"
43+
3744
- name: Install dependencies
3845
run: pnpm install --frozen-lockfile
3946

.github/workflows/dependabot-auto-merge.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ jobs:
1313
runs-on: ubuntu-latest
1414
if: ${{ github.actor == 'dependabot[bot]' }}
1515
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup pnpm
20+
uses: pnpm/action-setup@v4
21+
with:
22+
version: 10
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20.x'
28+
cache: 'pnpm'
29+
30+
- name: Configure Git merge driver for pnpm-lock.yaml
31+
run: |
32+
# Configure custom merge driver for pnpm-lock.yaml
33+
# This allows Git to automatically resolve lockfile conflicts by regenerating it
34+
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
35+
git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"
36+
1637
- name: Dependabot metadata
1738
id: metadata
1839
uses: dependabot/fetch-metadata@v2

0 commit comments

Comments
 (0)