Skip to content

Commit bb781fc

Browse files
committed
Update deploy scripts' git commands
1 parent 8592c7c commit bb781fc

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

ci/vulcan/build-for-ci.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
#!/usr/bin/env bash
22

33
# Build the webring at a particular commit hash and put it in the `/dev/shm/webring-ci` directory.
4-
#
4+
#
55
# The working directory is expected to be the highest directory of the git repo (~/webring)
66

77
set -e
88

99
if [ $# -ne 1 ]; then
10-
echo Expected one argument for the commit hash
10+
echo Error: expected one argument for the commit hash >&2
1111
exit 1
1212
fi
1313

14-
HASH=$1
14+
HASH="$1"
1515

1616
# Set up the testing directory in tmpfs
1717

1818
CI_PATH=/dev/shm/webring-ci
1919

20-
# Create the directory if it's not already created
21-
if ! [ -d $CI_PATH ]; then
22-
# Prevent other users from deleting/modifying our directory
23-
mkdir $CI_PATH --mode=700
20+
# Ensure there isn't a deployment already running
21+
if [ -d "$CI_PATH" ]; then
22+
echo "Error: $CI_PATH exists. Is there a CI job already running?" >&2
23+
exit 1
2424
fi
2525

26+
# Prevent other users from deleting/modifying our directory
27+
mkdir "$CI_PATH" --mode=700
28+
2629
# Checkout the commit into the testing directory
2730
# Use `--work-tree` to copy the code into the testing directory instead of the deployment directory. This doesn't copy `.git`.
28-
git fetch --all
29-
git --work-tree $CI_PATH checkout $HASH -- .
30-
cd $CI_PATH
31+
git fetch origin "$HASH"
32+
git -c advice.detachedHead=false --work-tree "$CI_PATH" restore --source="$HASH" --worktree -- :/
33+
cd "$CI_PATH"
3134

3235
# Build the flake
3336
nix build

ci/vulcan/deploy.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
set -e
66

77
if [ $# -ne 1 ]; then
8-
echo Expected one argument for the commit hash
8+
echo Error: expected one argument for the commit hash >&2
99
exit 1
1010
fi
1111

1212
HASH=$1
1313

1414
# Fetch and checkout the commit
15-
git fetch --all
16-
git checkout $HASH
15+
git fetch origin "$HASH"
16+
git -c advice.detachedHead=false checkout --force "$HASH"
1717

1818
# Reload home manager — Automatically rebuilds the webring and restarts the systemd unit.
1919
home-manager switch

0 commit comments

Comments
 (0)