Debian Codegraph @

.github/workflows/copilot-setup-steps.yml

raw
1 name: "Copilot Setup Steps"
2
3 # Automatically run the setup steps when they are changed to allow for easy
4 # validation, and allow manual testing through the repository's "Actions" tab.
5 on:
6 workflow_dispatch:
7 push:
8 paths:
9 - .github/workflows/copilot-setup-steps.yml
10 - .claude/hooks/session-start.sh
11 pull_request:
12 paths:
13 - .github/workflows/copilot-setup-steps.yml
14 - .claude/hooks/session-start.sh
15
16 jobs:
17 # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
18 copilot-setup-steps:
19 runs-on: ubuntu-latest
20 permissions:
21 contents: read
22 steps:
23 - name: Checkout code
24 uses: actions/checkout@v6
25
26 - name: Set up Python
27 uses: actions/setup-python@v6
28 with:
29 python-version: "3.x"
30
31 - name: Run Claude session-start hook to install libMBD and pyMBD
32 env:
33 # The shared hook gates its work on this flag; enable it here so the
34 # same setup that Claude uses also runs for the Copilot cloud agent.
35 CLAUDE_CODE_REMOTE: "true"
36 CLAUDE_PROJECT_DIR: ${{ github.workspace }}
37 CLAUDE_ENV_FILE: ${{ runner.temp }}/claude-env
38 run: |
39 set -euo pipefail
40 : >"$CLAUDE_ENV_FILE"
41 bash "$CLAUDE_PROJECT_DIR/.claude/hooks/session-start.sh"
42
43 - name: Export hook environment to subsequent steps
44 env:
45 CLAUDE_ENV_FILE: ${{ runner.temp }}/claude-env
46 run: |
47 set -euo pipefail
48 # Translate the `export KEY=VALUE` lines written by the hook into
49 # GitHub Actions' $GITHUB_ENV / $GITHUB_PATH so the venv and
50 # LIBMBD_PREFIX persist for any later steps the agent may run.
51 while IFS= read -r line; do
52 [ -z "$line" ] && continue
53 kv="${line#export }"
54 key="${kv%%=*}"
55 val="${kv#*=}"
56 # Expand variables like $PATH that the hook deferred.
57 val="$(eval printf '%s' \"$val\")"
58 if [ "$key" = "PATH" ]; then
59 # The hook writes PATH as "<prefix>:$PATH"; keep only the prefix.
60 prefix="${val%:$PATH}"
61 echo "$prefix" >> "$GITHUB_PATH"
62 else
63 echo "$key=$val" >> "$GITHUB_ENV"
64 fi
65 done < "$CLAUDE_ENV_FILE"