From f3d93e1e464f5e275e61fa26e5e923637aa29bb8 Mon Sep 17 00:00:00 2001 From: bartfaik04 Date: Sat, 7 Jun 2025 11:23:14 +0200 Subject: [PATCH] Merge 2 workflows into one --- .gitea/workflows/build.yml | 30 ---------------- .gitea/workflows/{release.yml => ci.yml} | 36 +++++++++++++++---- .gitignore | 3 +- ...service => ncsambawatcher.service.default} | 5 ++- init.sh | 8 ++--- 5 files changed, 37 insertions(+), 45 deletions(-) delete mode 100644 .gitea/workflows/build.yml rename .gitea/workflows/{release.yml => ci.yml} (58%) rename configs/{ncsambawatcher.service => ncsambawatcher.service.default} (66%) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml deleted file mode 100644 index f5cd41d..0000000 --- a/.gitea/workflows/build.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build - -on: - push: {} - -defaults: - run: - shell: bash - working-directory: . - -jobs: - build: - runs-on: ubuntu - container: - image: node:20 - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Install tools - run: apt update && apt install -y build-essential - - - name: Compile project - run: make - - - name: Save build output - uses: actions/upload-artifact@v3 - with: - name: ncsambawatcher - path: ./ncsambawatcher \ No newline at end of file diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/ci.yml similarity index 58% rename from .gitea/workflows/release.yml rename to .gitea/workflows/ci.yml index 084e811..4667d9c 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/ci.yml @@ -1,25 +1,48 @@ -name: Release +name: CI on: push: tags: - - v.* + - '*' # Triggers on all tags + branches: + - '**' # Triggers on all branches defaults: run: shell: bash working-directory: . -jobs: - release: +jobs: + build: runs-on: ubuntu + container: + image: node:20 + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install tools + run: apt update && apt install -y build-essential + + - name: Compile project + run: make + + - name: Save build output + uses: actions/upload-artifact@v3 + with: + name: ncsambawatcher + path: ./ncsambawatcher + + release: + if: startsWith(github.ref, 'refs/tags/') needs: build + runs-on: ubuntu container: image: node:20 steps: - name: Install build tools run: apt update && apt install -y zip - + - name: Download compiled binary uses: actions/download-artifact@v3 with: @@ -30,7 +53,8 @@ jobs: mkdir build cp ncsambawatcher build/ncsambawatcher cp configs/ncsambawatcher.config.default build/ncsambawatcher.config - cp init.sh config/init.sh + cp configs/ncsambawatcher.service.default build/ncsambawatcher.service + cp init.sh build/init.sh - name: Create release zip run: | diff --git a/.gitignore b/.gitignore index e5ce47e..7a33641 100644 --- a/.gitignore +++ b/.gitignore @@ -91,4 +91,5 @@ watch.c ncwatchfile ncsambawatcher -obj/ \ No newline at end of file +obj/ +build/ \ No newline at end of file diff --git a/configs/ncsambawatcher.service b/configs/ncsambawatcher.service.default similarity index 66% rename from configs/ncsambawatcher.service rename to configs/ncsambawatcher.service.default index f4f35f3..e6e3d42 100644 --- a/configs/ncsambawatcher.service +++ b/configs/ncsambawatcher.service.default @@ -4,12 +4,11 @@ After=network.target docker.service Requires=docker.service [Service] -ExecStart=/usr/bin/ncsambawatcher +ExecStart=/path/to/folder/ncsambawatcher +WorkingDirectory=/path/to/folder/ Restart=always User=root Group=root -WorkingDirectory=/usr/bin/ -Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin StandardOutput=journal StandardError=journal SyslogIdentifier=ncsambawatcher diff --git a/init.sh b/init.sh index 7f4e072..5e98a4c 100755 --- a/init.sh +++ b/init.sh @@ -1,11 +1,9 @@ #!/bin/bash -make +current_dir=$(pwd) +sed -i "s|/path/to/folder/|$current_dir/|g" ncsambawatcher.service -sudo cp ncsambawatcher /usr/bin/ -sudo chmod +x /usr/bin/ncsambawatcher - -sudo cp configs/ncsambawatcher.service /etc/systemd/system +sudo cp ./ncsambawatcher.service /etc/systemd/system sudo systemctl daemon-reload sudo systemctl enable ncsambawatcher.service