From 242a66f35300d7d7fa582d400fd9432c973e75aa Mon Sep 17 00:00:00 2001 From: Xyon Date: Tue, 8 Oct 2024 00:04:27 +0100 Subject: [PATCH] Complete string translation, add multihoming for M5 --- .gitea/workflows/deploy.yaml | 34 +++++++++++++++---- Cargo.lock | 1 - cicd/deploy.sh | 12 ++++--- config/production.badgey.json | 6 ++-- ...sponses.de.txt => responses.badgey.de.txt} | 0 ...sponses.en.txt => responses.badgey.en.txt} | 0 txt/responses.m5-computer.en.txt | 14 ++++++++ 7 files changed, 52 insertions(+), 15 deletions(-) rename txt/{responses.de.txt => responses.badgey.de.txt} (100%) rename txt/{responses.en.txt => responses.badgey.en.txt} (100%) create mode 100644 txt/responses.m5-computer.en.txt 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/cicd/deploy.sh b/cicd/deploy.sh index 680bf12..6553460 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 $bot@$bot sudo /usr/bin/systemctl stop $bot +rsync -avP badgey $bot@$bot:/srv/$bot/ +rsync -avP config $bot@$bot:/srv/$bot/ +rsync -avP txt $bot@$bot:/srv/$bot/ +ssh $bot@$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