@@ -43,56 +43,10 @@ jobs:
4343 with :
4444 testbox_id : ${{ inputs.testbox_id }}
4545 - name : Checkout
46- shell : bash
47- env :
48- CHECKOUT_REPO : ${{ github.repository }}
49- CHECKOUT_SHA : ${{ github.sha }}
50- CHECKOUT_TOKEN : ${{ github.token }}
51- run : |
52- set -euo pipefail
53-
54- workdir="$GITHUB_WORKSPACE"
55- if [[ -z "$CHECKOUT_TOKEN" ]]; then
56- echo "checkout token is missing" >&2
57- exit 1
58- fi
59- auth_header="$(printf 'x-access-token:%s' "$CHECKOUT_TOKEN" | base64 | tr -d '\n')"
60-
61- reset_checkout_dir() {
62- mkdir -p "$workdir"
63- find "$workdir" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
64- }
65-
66- checkout_attempt() {
67- local attempt="$1"
68-
69- reset_checkout_dir
70- git init "$workdir" >/dev/null
71- git config --global --add safe.directory "$workdir"
72- git -C "$workdir" remote add origin "https://github.com/${CHECKOUT_REPO}"
73- git -C "$workdir" config gc.auto 0
74-
75- timeout --signal=TERM --kill-after=10s 120s git -C "$workdir" \
76- -c protocol.version=2 \
77- -c "http.extraheader=AUTHORIZATION: basic ${auth_header}" \
78- fetch --no-tags --prune --no-recurse-submodules --depth=1 origin \
79- "+${CHECKOUT_SHA}:refs/remotes/origin/ci-target" || return 1
80-
81- git -C "$workdir" checkout --force --detach "$CHECKOUT_SHA" || return 1
82- test -f "$workdir/.github/actions/setup-node-env/action.yml" || return 1
83- echo "checkout attempt ${attempt}/5 succeeded"
84- }
85-
86- for attempt in 1 2 3 4 5; do
87- if checkout_attempt "$attempt"; then
88- exit 0
89- fi
90- echo "checkout attempt ${attempt}/5 failed"
91- sleep $((attempt * 5))
92- done
93-
94- echo "checkout failed after 5 attempts" >&2
95- exit 1
46+ uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
47+ with :
48+ fetch-depth : ${{ github.event_name == 'pull_request' && '2' || '0' }}
49+ persist-credentials : false
9650 - name : Setup Node environment
9751 uses : ./.github/actions/setup-node-env
9852 with :
@@ -103,34 +57,9 @@ jobs:
10357 sticky-disk : ${{ github.event_name == 'workflow_dispatch' && 'true' || 'false' }}
10458 use-actions-cache : ${{ github.event_name == 'workflow_dispatch' && 'false' || 'true' }}
10559 - name : Prepare Testbox shell
106- shell : bash
107- run : |
108- set -euo pipefail
109-
110- timeout --signal=TERM --kill-after=10s 120s git \
111- -c protocol.version=2 \
112- fetch --no-tags --prune --no-recurse-submodules --depth=50 origin \
113- "+refs/heads/main:refs/remotes/origin/main"
114-
115- node_bin="$(dirname "$(node -p 'process.execPath')")"
116- link_node_tool() {
117- local tool="$1"
118- local source="$node_bin/$tool"
119- local target="/usr/local/bin/$tool"
120- if [ -e "$target" ] && [ "$(readlink -f "$source")" = "$(readlink -f "$target")" ]; then
121- return
122- fi
123- sudo ln -sf "$source" "$target"
124- }
125- link_node_tool node
126- link_node_tool npm
127- link_node_tool npx
128- link_node_tool corepack
129- sudo tee /usr/local/bin/pnpm >/dev/null <<'PNPM'
130- #!/usr/bin/env bash
131- exec /usr/local/bin/corepack pnpm "$@"
132- PNPM
133- sudo chmod 0755 /usr/local/bin/pnpm
60+ uses : ./.github/actions/prepare-testbox-shell
61+ with :
62+ base-ref : ${{ github.event.pull_request.base.sha || 'refs/remotes/origin/main' }}
13463
13564 - name : Hydrate Testbox provider env helper
13665 shell : bash
0 commit comments