Skip to content

Commit

Permalink
ci: update config tu use user service unit
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilhermeasper committed Apr 10, 2024
1 parent 4cf52c6 commit eed7251
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:

jobs:
build:
runs-on: [self-hosted, Linux, X64]
runs-on: [self-hosted-marquinhos, Linux, X64]

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -24,9 +24,23 @@ jobs:
- run: npm run build
deploy:
needs: build
runs-on: [self-hosted, Linux, X64]
runs-on: [self-hosted, Linux, X64, marquinhos-ci]
steps:
- name: Make deploy.sh executable
run: chmod +x ./deploy.sh
- name: Execute deploy.sh
run: echo "${{ secrets.DVNS_CLUSTER_PASSWORD }}" | sudo -S ./deploy.sh "$(pwd)/dist"
- name: Stop service
run: systemctl --user stop marquinhos-bot.service
- name: Copy service file
run: cp marquinhos-bot.service ~/.config/systemd/user/marquinhos-bot.service
- name: Reload systemd
run: systemctl --user daemon-reload
- name: Start service
run: systemctl --user start marquinhos-bot.service
- name: Check status
id: check-status
run:
if [ "$(systemctl --user is-active marquinhos-bot.service)" != "active" ]; then
echo "Service is not running or has failed"
exit 1
fi
- name: Fail if service is not running
if: steps.check-status.outcome != 'success'
run: exit 1
17 changes: 17 additions & 0 deletions marquinhos-bot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=MarquinhosBOT
After=network.target

[Service]
EnvironmentFile=/etc/marquinhos/marquinhos.conf
Environment="NODE_ENV=production"
User=marquinhos
WorkingDirectory=$DESTINATION_DIR
ExecStart=node -r tsconfig-paths/register ./index.js
Restart=always
RestartSec=30
StartLimitInterval=0


[Install]
WantedBy=default.target

0 comments on commit eed7251

Please sign in to comment.