ci(wallpaper_changer): add CICD debugging
Serverlibrary CI / test-serverlibrary (push) Successful in 9s
Serverlibrary CI / lint-serverlibrary (push) Successful in 6s
Wallpaper Changer CI / test-wallpaper-changer (push) Successful in 18s
Wallpaper Changer CI / build (push) Skipped
Wallpaper Changer CI / install (push) Skipped
Wallpaper Changer CI / lint-wallpaper-changer (push) Successful in 7s
Serverlibrary CI / test-serverlibrary (pull_request) Successful in 9s
Serverlibrary CI / lint-serverlibrary (pull_request) Successful in 6s
Serverlibrary CI / test-serverlibrary (push) Successful in 9s
Serverlibrary CI / lint-serverlibrary (push) Successful in 6s
Wallpaper Changer CI / test-wallpaper-changer (push) Successful in 18s
Wallpaper Changer CI / build (push) Skipped
Wallpaper Changer CI / install (push) Skipped
Wallpaper Changer CI / lint-wallpaper-changer (push) Successful in 7s
Serverlibrary CI / test-serverlibrary (pull_request) Successful in 9s
Serverlibrary CI / lint-serverlibrary (pull_request) Successful in 6s
This commit is contained in:
1 parent
02c53e0839
commit
1e35b34568
1 file changed
+58
-36
@@ -110,72 +110,94 @@ jobs:
|
||||
name: wallpaper-changer-build
|
||||
path: wallpaper_changer/python/dist/
|
||||
if-no-files-found: error
|
||||
|
||||
install:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
needs: build
|
||||
runs-on: [self-hosted, linux, x64]
|
||||
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Check runner environment
|
||||
run: |
|
||||
set -eux
|
||||
whoami
|
||||
echo "$HOME"
|
||||
id
|
||||
echo "UID: $(id -u)"
|
||||
echo "Checking user systemd bus..."
|
||||
ls -l "/run/user/$(id -u)/bus" || true
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: https://github.com/christopherHX/gitea-download-artifact@v4
|
||||
with:
|
||||
name: wallpaper-changer-build
|
||||
path: dist/
|
||||
|
||||
|
||||
- name: Verify downloaded artifacts
|
||||
run: |
|
||||
set -eux
|
||||
ls -lah dist/
|
||||
test -f dist/wallpaper_changer
|
||||
test -f dist/wallpaper-changer.service
|
||||
|
||||
- name: Install executable and provision private key
|
||||
env:
|
||||
WALLPAPER_PRIVATE_KEY_PEM: ${{ secrets.WALLPAPER_PRIVATE_KEY_PEM }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
validate_private_key() {
|
||||
if [ "$(head -n 1 "$1")" != "-----BEGIN RSA PRIVATE KEY-----" ]; then
|
||||
echo "Expected an unencrypted RSA PKCS#1 PEM private key." >&2
|
||||
return 1
|
||||
fi
|
||||
openssl pkey -in "$1" -noout
|
||||
}
|
||||
|
||||
|
||||
echo "1. Preparing directories"
|
||||
key_dir="$HOME/.wallpaper"
|
||||
key_file="$key_dir/private_key.pem"
|
||||
install -d -m 700 "$key_dir"
|
||||
|
||||
install -d -m 755 "$HOME/tools"
|
||||
|
||||
echo "2. Checking private key"
|
||||
if [ -L "$key_file" ] || { [ -e "$key_file" ] && [ ! -f "$key_file" ]; }; then
|
||||
echo "Refusing to use a non-regular key path: $key_file" >&2
|
||||
echo "Invalid key path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ -f "$key_file" ]; then
|
||||
validate_private_key "$key_file"
|
||||
chmod 600 "$key_file"
|
||||
echo "Preserving the existing private key."
|
||||
echo "Preserving existing key"
|
||||
else
|
||||
: "${WALLPAPER_PRIVATE_KEY_PEM:?Set the WALLPAPER_PRIVATE_KEY_PEM Gitea secret for first-time installation}"
|
||||
: "${WALLPAPER_PRIVATE_KEY_PEM:?Missing private key secret}"
|
||||
|
||||
temporary_key="$(mktemp "$key_dir/.private_key.XXXXXX")"
|
||||
trap 'rm -f "$temporary_key"' EXIT
|
||||
|
||||
printf '%s' "$WALLPAPER_PRIVATE_KEY_PEM" > "$temporary_key"
|
||||
validate_private_key "$temporary_key"
|
||||
|
||||
test "$(head -n 1 "$temporary_key")" = "-----BEGIN RSA PRIVATE KEY-----"
|
||||
openssl pkey -in "$temporary_key" -noout
|
||||
|
||||
chmod 600 "$temporary_key"
|
||||
if ln "$temporary_key" "$key_file"; then
|
||||
echo "Installed the private key with mode 600."
|
||||
elif [ -f "$key_file" ]; then
|
||||
validate_private_key "$key_file"
|
||||
chmod 600 "$key_file"
|
||||
echo "Preserving the private key installed concurrently."
|
||||
else
|
||||
echo "Failed to install the private key." >&2
|
||||
exit 1
|
||||
fi
|
||||
ln "$temporary_key" "$key_file"
|
||||
echo "Private key installed"
|
||||
fi
|
||||
|
||||
install -d -m 755 "$HOME/tools"
|
||||
|
||||
echo "3. Installing executable"
|
||||
install -m 755 dist/wallpaper_changer "$HOME/tools/wallpaper_changer"
|
||||
|
||||
|
||||
echo "4. Installing systemd service"
|
||||
user_unit_dir="$HOME/.config/systemd/user"
|
||||
install -d -m 755 "$user_unit_dir"
|
||||
install -m 644 dist/wallpaper-changer.service "$user_unit_dir/wallpaper-changer.service"
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable wallpaper-changer.service
|
||||
systemctl --user start --no-block wallpaper-changer.service
|
||||
|
||||
echo "5. Connecting to user systemd"
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
|
||||
|
||||
test -S "$XDG_RUNTIME_DIR/bus"
|
||||
|
||||
echo "6. Reloading systemd"
|
||||
timeout 15s systemctl --user daemon-reload
|
||||
|
||||
echo "7. Enabling service"
|
||||
timeout 15s systemctl --user enable wallpaper-changer.service
|
||||
|
||||
echo "8. Starting service"
|
||||
timeout 15s systemctl --user start --no-block wallpaper-changer.service
|
||||
|
||||
echo "9. Installation completed"
|
||||
Reference in new issue
Block a user