Skip to content

Commit

Permalink
ci(github-actions): setup CI for Nest deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhalili2006 committed Jan 29, 2025
1 parent 2458b90 commit b1487ab
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ DOTENV_PUBLIC_KEY_PRODUCTION="031c733507101704b9bcd0a852a195c4728e64b09e75feca68
# This is the production environment configuration file
# for HCB Explorer Discord bot, used at Hack Club Nest.
DISCORD_BOT_TOKEN="encrypted:BIdbL44fnvHirm9WBI1O4kbWeW2u04T8LmyxFkqBG2QXqfiT1IKygaMg8vqZeNzFh6SiEBKJ2M0VLzQWda/eHecEcbiwEb8WPBm+bKD5SDZJCat/f9sHlZqSzuXS+9c82S/1MSDDI3xXunfkVPVoRqJJFTFUURneKVMU0WvJ/XBAwovrDuYvyBNheqAa089uqelRxwUFV8j90hAzKj85Hm2R9sJo2vrrXQ=="
DUSCORD_BOT_APP_ID=1318460909567475722
DISCORD_BOT_APP_ID=1318460909567475722
SENTRY_DSN="encrypted:BFB7eLx6B6fZLEvtHUPjs2zSqOdus655SwhQmOaO5WUl3z36OP6cfBk/iAbFnqbV+yQtn39l/D80dyZs4AjQNzqD1Tv2mg6jh1ZGHSJa5UUzf7dTSVVrTn0QwnY9oLhSIpDVWiMgFrxyR8dbDaoS6rmS76xcToXyLdfYRjp3XmBcQYkTCLsT70VXnNumsXl8YK7PvoM8Yz+BRcIDpBb4DiBPHa6+y7Fqifmsha01ceQV/pK3CbU="
NODE_ENV="production"
NODE_ENV="production"
PORT=44609
PUBLIC_URL="https://hcb-explorer-discordbot.ajhalili2006.hackclub.app"
50 changes: 50 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deployments

on:
push:
branches:
- main
paths:
- src/**
- package*.json
- .github/workflows/deploy.yml
- .env*
workflow_dispatch:

jobs:
nest:
name: Hack Club Nest
runs-on: ubuntu-24.04
environment:
name: nest/production
url: https://hcb-explorer-discordbot.ajhalili2006.hackclub.app
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get Doppler Secrets
id: doppler
uses: DopplerHQ/[email protected]
with:
doppler-token: ${{secrets.DOPPLER_TOKEN}}
- name: Install SSH key of bastion
uses: shimataro/ssh-key-action@v2
with:
key: ${{steps.doppler.outputs.NEST_SSH_PRIVATE_KEY}}
name: ajhalili2006-passwordless
known_hosts: |
hackclub.app ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNzIySdwx0OqVCH8vFBDkQwsWJ4h0mVN1F2Al840f0zuF/5BjF5TQDvlZXlTtT7NpKsBga4tkk4VMnA3lHc8WYY=
hackclub.app ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCkQnX8cBdKobrNL8xCoS+Z1vNRcWcmj2kGhZsgfzF91Rmj2iX/kTC4qQvm/2yYUb58AULew+tuwaZitUCIpUIA6qn41rURpzYf5Yuf0Xjy9DeJwZmBuw6jjoKMYcy1nD/eDMvSMyIKpr0Yygqfdw7F8VghJzKeG/CEqfZkBV1993ad9G0usl74gPrgIb524FeTnrNr+G3NXs53VtvBY7TrpJK2wHLlLfMm6mXk3C7AI5AYaGRo+3PndqhmGnfQndgj3oK6AZAYQHR8XXrZEZt6eptNdi5vQs+VvNZHCVLB4AO3O+IgVfVh6Pm+Y1nXk13coTXJtfI4grrxAVjIbGzrCUC9Gr34u7037xUyvgVPLMHhEWc7zw5YqBotptz0IUE6Qjffa3NaBdM4oRsdEXK5VmPlowsxeHVz0H+S8omL8stRtOA37SXhP8nepH1Eqo5/cyVo/pR0+JsEBqptHAjJ19qEz3qUl+i5YB84ewyq3hDLOA3+p8fCwcV+oZp/u9c=
hackclub.app ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ3pezDUZG+4bPRZg2znAuuMp42AL+rc1HGUltnNf8cA
config: |
Host nest
Hostname hackclub.app
User ajhalili2006
IdentityFile ~/.ssh/ajhalili2006-passwordless
- name: Update code on nest
run: |
ssh nest git -C /home/ajhalili2006/git/hcb-explorer-discord pull
ssh nest cp -v /home/ajhalili2006/git/hcb-explorer-discord/src/lib/hcb-explorer-discordbot-nest.service /home/ajhalili2006/.config/systemd/user
ssh nest bash -c "set -x; cd /home/ajhalili2006/git/hcb-explorer-discord && npm i"
ssh nest systemctl --user daemon-reload
ssh nest systemctl --user start leeksbot-nest
11 changes: 11 additions & 0 deletions src/lib/hcb-explorer-discordbot-nest.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=HCB Explorer Discord bot

[Service]
ExecStart=/home/ajhalili2006/.nix-profile/bin/npm start
WorkingDirectory=/home/ajhalili2006/git/hcb-explorer-discord
RestartSec=5s
Restart=on-failure

[Install]
WantedBy=default.target

0 comments on commit b1487ab

Please sign in to comment.