Skip to content

Commit 1f26254

Browse files
committed
fix(ci): robust git isolation and early installation
1. Redirected GIT_CONFIG_GLOBAL to /tmp and added 'touch' to ensure writeability and prevent lock file errors. 2. Moved 'Install Git' to the top of the e2e-test job to ensure 'actions/checkout' creates a proper .git directory.
1 parent 0d98b93 commit 1f26254

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ jobs:
2929

3030
- name: Configure Git User
3131
run: |
32-
# Redirect global git config to a file in the workspace to avoid polluting the host system
33-
echo "GIT_CONFIG_GLOBAL=${{ github.workspace }}/.gitconfig_ci" >> $GITHUB_ENV
34-
export GIT_CONFIG_GLOBAL="${{ github.workspace }}/.gitconfig_ci"
32+
# Redirect global git config to a file in /tmp to avoid polluting the host system
33+
# and ensure we have write permissions regardless of the workspace setup.
34+
touch /tmp/.gitconfig_ci
35+
echo "GIT_CONFIG_GLOBAL=/tmp/.gitconfig_ci" >> $GITHUB_ENV
36+
export GIT_CONFIG_GLOBAL="/tmp/.gitconfig_ci"
3537
git config --global user.email "ci@git-cms.local"
3638
git config --global user.name "CI Bot"
3739
git config --global init.defaultBranch main
@@ -56,22 +58,20 @@ jobs:
5658
container:
5759
image: mcr.microsoft.com/playwright:v1.57.0-jammy
5860
steps:
59-
- uses: actions/checkout@v4
60-
61-
- uses: actions/setup-node@v4
62-
with:
63-
node-version: '22'
64-
cache: 'npm'
65-
66-
# Git is required in the container to perform plumbing operations during E2E tests
61+
# Git is required in the container to perform plumbing operations during E2E tests.
62+
# Installing it BEFORE checkout ensures actions/checkout performs a real clone.
6763
- name: Install Git
6864
run: apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
65+
66+
- uses: actions/checkout@v4
6967

7068
- name: Configure Git User
7169
run: |
72-
# Redirect global git config to a file in the workspace to avoid polluting the host system
73-
echo "GIT_CONFIG_GLOBAL=${{ github.workspace }}/.gitconfig_ci" >> $GITHUB_ENV
74-
export GIT_CONFIG_GLOBAL="${{ github.workspace }}/.gitconfig_ci"
70+
# Redirect global git config to a file in /tmp to avoid polluting the host system
71+
# and ensure we have write permissions regardless of the workspace setup.
72+
touch /tmp/.gitconfig_ci
73+
echo "GIT_CONFIG_GLOBAL=/tmp/.gitconfig_ci" >> $GITHUB_ENV
74+
export GIT_CONFIG_GLOBAL="/tmp/.gitconfig_ci"
7575
git config --global user.email "ci@git-cms.local"
7676
git config --global user.name "CI Bot"
7777
git config --global init.defaultBranch main

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ All notable changes to git-cms are documented in this file.
66

77
### Fixed
88

9-
- **(Security) Git identity leakage:** Removed `git config --global` from host-level modification in CI workflow (`.github/workflows/ci.yml`). Scripts now use an isolated global config file via `GIT_CONFIG_GLOBAL` redirected to the workspace, preventing accidental modification of host global settings if workflows are executed locally (e.g., via `act`).
9+
- **(Security) Git identity leakage:** Removed `git config --global` from host-level modification in CI workflow (`.github/workflows/ci.yml`). Scripts now use an isolated global config file via `GIT_CONFIG_GLOBAL` redirected to `/tmp`, preventing accidental modification of host global settings if workflows are executed locally (e.g., via `act`).
1010
- `QUICK_REFERENCE.md`: `revert` command description corrected — sets state to `reverted`, not `draft`
1111
- `QUICK_REFERENCE.md`: state machine diagram refined to accurately show `draft``reverted` transition
1212
- `QUICK_REFERENCE.md`: HTTP API table uses canonical `optional` notation and clarifies optimistic concurrency for `publish`

0 commit comments

Comments
 (0)