Skip to content

Commit 9d3e819

Browse files
committed
build-and-deploy: use a home directory with a shorter path
The path `${{ github.workspace }}/home` was apparently almost too long already, with the repository name `git-for-windows-automation` repeated _twice_ in it, and when we started using self-hosted runners whose agent directory is called `C:\actions-runner` (as opposed to GitHub hosted runners that have it in `D:\a`), it tipped the balance. This matters because we want to use GNU Privacy Guard, which insists on the full path of the `gpg-agent` socket to fit inside `sockaddr_un.sun_path` (which only 108 bytes long). The symptom we see is that importing GPG keys fails with a lapidary "gpg: can't connect to the agent: IPC connect call failed". The secret is lifted only when debugging a big further, e.g. by adding a `gpg-agent.conf` in `$HOME/.gnupg/` with contents like this one: debug-level guru debug-all log-file /tmp/gpg-agent.debug.log Then, that log file will contain some hints like this one: 2023-01-02 20:46:25 gpg-agent[1018] listening on socket '/c/actions-runner/_work/git-for-windows-automation/git-for-windows-automation/home//.gnupg/S.gpg-agent' 2023-01-02 20:46:25 gpg-agent[1018] socket name '/c/actions-runner/_work/git-for-windows-automation/git-for-windows-automation/home//.gnupg/S.gpg-agent.extra' is too long A similar issue was reported at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=847206, but sadly the suggested command `gpgconf --create-socketdir` fails, not only because `/run/user/<uid>` does not exist, but even when that directory is created, the command falls prey to the vast differences between Windows' and Unix' permission model, and it thinks that the directory's permissions are too lax and refuses to do its job. So let's do the next best thing and use a home directory that is not inside a deep path, but instead directly inside the runner's temporary path. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f5c6930 commit 9d3e819

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ env:
3131
REF: "${{ github.event.inputs.ref }}"
3232
ARCHITECTURE: "${{ github.event.inputs.architecture }}"
3333
GPG_OPTIONS: "--batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback"
34-
HOME: "${{ github.workspace }}\\home"
3534
ACTOR: "${{ github.event.inputs.actor || github.triggering_actor }}"
3635
CREATE_CHECK_RUN: true
3736

@@ -117,6 +116,8 @@ jobs:
117116
run: |
118117
USER_NAME="${{ steps.actor.outputs.name }}" &&
119118
USER_EMAIL="${{ steps.actor.outputs.email }}" &&
119+
HOME="${{ runner.temp }}\\home" &&
120+
echo "HOME=$HOME" >>$GITHUB_ENV &&
120121
mkdir -p "$HOME" &&
121122
git config --global user.name "$USER_NAME" &&
122123
git config --global user.email "$USER_EMAIL" &&
@@ -204,7 +205,7 @@ jobs:
204205
shell: bash
205206
run: |
206207
echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import &&
207-
mkdir -p home &&
208+
mkdir -p "$HOME" &&
208209
git config --global gpg.program "/usr/src/build-extra/gnupg-with-gpgkey.sh" &&
209210
info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" &&
210211
git config --global user.name "${info% <*}" &&
@@ -220,9 +221,9 @@ jobs:
220221
CODESIGN_PASS: ${{secrets.CODESIGN_PASS}}
221222
shell: bash
222223
run: |
223-
mkdir -p home/.sig &&
224-
echo "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 &&
225-
echo "$CODESIGN_PASS" >home/.sig/codesign.pass
224+
mkdir -p "$HOME"/.sig &&
225+
echo "$CODESIGN_P12" | tr % '\n' | base64 -d >"$HOME"/.sig/codesign.p12 &&
226+
echo "$CODESIGN_PASS" >"$HOME"/.sig/codesign.pass
226227
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
227228
echo "SIGNTOOL=git signtool" >>$GITHUB_ENV
228229
@@ -302,7 +303,7 @@ jobs:
302303
- name: Clean up temporary files
303304
if: always()
304305
shell: bash
305-
run: rm -rf home
306+
run: rm -rf "$HOME"
306307

307308
- name: mark check run as completed
308309
if: env.CREATE_CHECK_RUN != 'false' && always()

0 commit comments

Comments
 (0)