Skip to content

Commit dbe84c5

Browse files
committed
gh actions: specify deploy action with Deploy-action git trailer
- adds support for specifying the colmena deploy action with the git trailer: "Deploy-action: <valid action here>" - defaults to switch when the specified action is invalid or the trailer is not there. - only applies when the trailer is on HEAD inside the actions checkout. this is very useful when we want a push to main to only apply after a reboot, for example :)
1 parent 4c9d889 commit dbe84c5

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/auto-deploy.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ jobs:
4949
env:
5050
SSH_CONFIG_FILE: ${{ github.workspace }}/ssh_config
5151
run: |
52+
# parse "Deploy-action" git trailer
53+
action="$(
54+
git log -1 --format='%(trailers:key=Deploy-action,valueonly)' \
55+
| tr '[:upper:]' '[:lower:]' \
56+
| tr -d '\n'
57+
)"
58+
59+
# default to switch unless valid alternative is provided
60+
case "$action" in
61+
build|push|switch|boot|test|dry-activate|upload-keys) ;;
62+
*) action=switch ;;
63+
esac
64+
5265
echo "$HOSTS" | tr ' ' '\n' | \
5366
xargs -P 10 -n 1 -I {} \
5467
nix develop .#deploy -c sh -c "
@@ -64,7 +77,7 @@ jobs:
6477
exit
6578
fi
6679
67-
if colmena apply --on {} switch > {}.log 2>&1; then
80+
if colmena apply --on {} "$action" > {}.log 2>&1; then
6881
echo '✅ Successfully deployed to {}'
6982
echo 'SUCCESS:{}' >> results.txt
7083
else

0 commit comments

Comments
 (0)