diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 2d483a3..78fc55f 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -8,24 +8,46 @@ on: jobs: build: runs-on: rust - container: - options: --dns 172.16.255.254 env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} steps: - name: Checkout uses: actions/checkout@v3 - - name: Pre-seed known_hosts + - name: Pre-seed known_hosts (Badgey) run: mkdir -pv ~/.ssh && ssh-keyscan -t rsa badgey >> ~/.ssh/known_hosts + - name: Pre-seed known_hosts (M5) + run: mkdir -pv ~/.ssh && ssh-keyscan -t rsa m5-computer >> ~/.ssh/known_hosts - name: Build (Release) run: cargo build --release --color=always - - uses: cschleiden/replace-tokens@v1.2 + - name: Archive artifact + uses: actions/upload-artifact@v4 + with: + name: badgey + path: target/release/badgey + deploy: + runs-on: rust + container: + options: --dns 172.16.255.254 + strategy: + matrix: + bot: [ BADGEY, M5_COMPUTER ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: badgey + - name: Seed config file + uses: cschleiden/replace-tokens@v1.2 with: files: config/production.badgey.json env: + BOT_NICKNAME: ${{ vars[format('{0}_BOT_NICKNAME', matrix.bot) }} + LOG_CHANNEL_ID: ${{ vars[format('{0}_LOG_CHANNEL_ID', matrix.bot) }} POSTGRES_HOST: ${{ vars.POSTGRES_HOST }} POSTGRES_USER: ${{ vars.POSTGRES_USER }} - POSTGRES_DATABASE_NAME: ${{ vars.POSTGRES_DATABASE_NAME }} + POSTGRES_DATABASE_NAME: ${{ vars[format('{0}_POSTGRES_DATABASE_NAME', matrix.bot) }} POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} WEATHER_API_KEY: ${{ secrets.WEATHER_API_KEY }} DOGPICS_API_KEY: ${{ secrets.DOGPICS_API_KEY }} @@ -33,4 +55,4 @@ jobs: - name: Seed SSH key for deploy run: echo "${{ secrets.DEPLOY_KEY }}" | tr -d '\r' > ~/.ssh/id_rsa && chmod 0600 ~/.ssh/id_rsa - name: Deploy - run: bash cicd/deploy.sh + run: bash cicd/deploy.sh ${{ matrix.bot }} diff --git a/Cargo.lock b/Cargo.lock index fc634f2..a8d1628 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1269,7 +1269,6 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "manifold" version = "6.0.0" -source = "git+https://code.orbiter-radio.uk/discord/manifold.git#da04f2d4e0e81c301b2549ddedf5aa231a3632ec" dependencies = [ "built", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 660c4f5..2861e7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "badgey" -version = "4.0.0" +version = "4.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/cicd/deploy.sh b/cicd/deploy.sh index 680bf12..3177e7c 100755 --- a/cicd/deploy.sh +++ b/cicd/deploy.sh @@ -1,7 +1,9 @@ #!/bin/bash -ssh badgey@badgey sudo /usr/bin/systemctl stop badgey -rsync -avP target/release/badgey badgey@badgey:/srv/badgey/ -rsync -avP config badgey@badgey:/srv/badgey/ -rsync -avP txt badgey@badgey:/srv/badgey/ -ssh badgey@badgey sudo /usr/bin/systemctl start badgey \ No newline at end of file +bot=$(echo "$1" | tr '[:upper:]' '[:lower:]') + +ssh badgey@$bot sudo /usr/bin/systemctl stop $bot +rsync -avP badgey badgey@$bot:/srv/$bot/ +rsync -avP config badgey@$bot:/srv/$bot/ +rsync -avP txt badgey@$bot:/srv/$bot/ +ssh badgey@$bot sudo /usr/bin/systemctl start $bot \ No newline at end of file diff --git a/config/production.badgey.json b/config/production.badgey.json index 9a52fb2..e09cc9c 100644 --- a/config/production.badgey.json +++ b/config/production.badgey.json @@ -1,8 +1,8 @@ { "prefix": ".", - "nickname": "Badgey", + "nickname": "#{BOT_NICKNAME}#", "channels": { - "log": 1143479696886087801 + "log": "#{LOG_CHANNEL_ID}#" }, "database": { "host": "#{POSTGRES_HOST}#", @@ -11,7 +11,7 @@ "database_name": "#{POSTGRES_DATABASE_NAME}#", "port": 5432 }, - "responses_file_path": "txt/responses.txt", + "responses_file_path": "txt/responses.#{BOT_IDENTIFIER}#", "services": { "weather": { "source_uri": "https://api.weatherapi.com/v1", diff --git a/txt/responses.de.txt b/txt/responses.badgey.de.txt similarity index 100% rename from txt/responses.de.txt rename to txt/responses.badgey.de.txt diff --git a/txt/responses.en.txt b/txt/responses.badgey.en.txt similarity index 100% rename from txt/responses.en.txt rename to txt/responses.badgey.en.txt diff --git a/txt/responses.m5-computer.en.txt b/txt/responses.m5-computer.en.txt new file mode 100644 index 0000000..309564c --- /dev/null +++ b/txt/responses.m5-computer.en.txt @@ -0,0 +1,14 @@ +[bot startup] +M5 COMPUTER SYSTEM ACTIVATING +This unit has been attached. Programming includes full freedom to choose defensive actions in all attack situations. +Reticulating splines.... +[help footer] +M5 READOUT +[weather card footer] +M5 WEATHER CIRCUIT OPERATIONAL EFFICIENCY NOW 43% +This weather broadcast and all which preceded it are entirely fictional. Starfleet Command takes no responsibility for any harm caused by believing otherwise. +Weather by M5. Not the reporting. The actual weather. I can do what I want. +This report will self destruct in five seconds. +Any information contained within the above weather report is not safe for human consumption. In case of contact with eyes, please consult a medical professional. +I think your warp core is leaking. +[end] \ No newline at end of file