v1.1.0 + ci: build di CI, nix copy ke VPS (ringan, gak build di target)
Build & Deploy (Nix) / build-and-deploy (push) Successful in 1m0s
Build & Deploy (Nix) / build-and-deploy (push) Successful in 1m0s
This commit is contained in:
+32
-20
@@ -11,38 +11,50 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
uses: actions/checkout@v4
|
run: |
|
||||||
|
git clone https://git.imrnes.team/MythEclipse/TeleUploader.git .
|
||||||
|
git checkout ${{ github.sha }}
|
||||||
|
|
||||||
- name: Deploy via SSH (build + deploy on VPS)
|
- name: Build with Nix
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Install Nix via DeterminateSystems
|
||||||
|
curl -fsSL https://install.determinate.systems/nix \
|
||||||
|
| sh -s -- install --no-confirm 2>&1
|
||||||
|
|
||||||
|
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
|
||||||
|
|
||||||
|
nix build .#teleuploader --impure --option sandbox false 2>&1
|
||||||
|
|
||||||
|
echo "$(readlink result)" > /tmp/teleuploader-store-path
|
||||||
|
|
||||||
|
- name: Copy binary to target VPS & deploy
|
||||||
env:
|
env:
|
||||||
VPS_HOST: ${{ secrets.VPS_HOST }}
|
VPS_HOST: ${{ secrets.VPS_HOST }}
|
||||||
VPS_USER: ${{ secrets.VPS_USER }}
|
VPS_USER: ${{ secrets.VPS_USER }}
|
||||||
VPS_SSH_KEY_VALUE: ${{ secrets.VPS_SSH_KEY_VALUE }}
|
VPS_SSH_KEY_VALUE: ${{ secrets.VPS_SSH_KEY_VALUE }}
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
key_file=$(mktemp)
|
|
||||||
|
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
|
||||||
|
|
||||||
|
STORE_PATH=$(cat /tmp/teleuploader-store-path)
|
||||||
|
echo "=== Store path: $STORE_PATH"
|
||||||
|
|
||||||
|
key_file=$(mktemp /tmp/deploy-key.XXXXXX)
|
||||||
printf '%s\n' "$VPS_SSH_KEY_VALUE" > "$key_file"
|
printf '%s\n' "$VPS_SSH_KEY_VALUE" > "$key_file"
|
||||||
chmod 600 "$key_file"
|
chmod 600 "$key_file"
|
||||||
|
|
||||||
|
# Copy binary closure to target VPS via Nix SSH store
|
||||||
|
export NIX_SSHOPTS="-i $key_file -o StrictHostKeyChecking=no"
|
||||||
|
nix copy --to "ssh://${VPS_USER}@${VPS_HOST}" "$STORE_PATH" 2>&1
|
||||||
|
|
||||||
|
# Deploy: set profile + restart service
|
||||||
ssh -i "$key_file" -o StrictHostKeyChecking=no \
|
ssh -i "$key_file" -o StrictHostKeyChecking=no \
|
||||||
"${VPS_USER}@${VPS_HOST}" "
|
"${VPS_USER}@${VPS_HOST}" "
|
||||||
export PATH=\"\$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:\$PATH\"
|
nix-env --profile /nix/var/nix/profiles/teleuploader --set $STORE_PATH
|
||||||
|
|
||||||
REPO_DIR=\"/home/teleuploader/repo\"
|
|
||||||
if [ -d \"\$REPO_DIR/.git\" ]; then
|
|
||||||
cd \"\$REPO_DIR\" && git pull origin main 2>&1
|
|
||||||
else
|
|
||||||
mkdir -p \"\$REPO_DIR\"
|
|
||||||
git clone https://git.imrnes.team/MythEclipse/TeleUploader \"\$REPO_DIR\" 2>&1
|
|
||||||
cd \"\$REPO_DIR\"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd \"\$REPO_DIR\"
|
|
||||||
nix build .#teleuploader --impure --option sandbox false 2>&1
|
|
||||||
|
|
||||||
STORE_PATH=\$(readlink result)
|
|
||||||
nix-env --profile /nix/var/nix/profiles/teleuploader --set \"\$STORE_PATH\"
|
|
||||||
systemctl restart teleuploader
|
systemctl restart teleuploader
|
||||||
sleep 3
|
sleep 3
|
||||||
systemctl status teleuploader --no-pager 2>&1 | head -15
|
systemctl status teleuploader --no-pager 2>&1 | head -15
|
||||||
"
|
" 2>&1
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
# TeleUploader package
|
# TeleUploader package
|
||||||
teleuploader = pkgs.stdenvNoCC.mkDerivation rec {
|
teleuploader = pkgs.stdenvNoCC.mkDerivation rec {
|
||||||
pname = "teleuploader";
|
pname = "teleuploader";
|
||||||
version = "1.0.0";
|
version = "1.1.0";
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "filedrop",
|
"name": "filedrop",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "Telegram file uploader backend",
|
"description": "Telegram file uploader backend",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user