improve formatting for bot token missing message #58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build release binary | |
run: cargo build --release --verbose | |
- name: Save build artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: neomason-bin | |
path: target/release/neomason-discord-bot | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Announce deploy | |
env: | |
DISCORD_TOKEN: ${{ secrets.BOT_DISCORD_TOKEN }} | |
CHANNEL_ID: ${{ secrets.ANNOUNCEMENT_CHANNEL_ID }} | |
run: | | |
msg=$(git log --oneline --no-decorate | cut -f2- -d ' ' | head -n1) | |
curl https://discord.com/api/channels/${CHANNEL_ID}/messages -H "Authorization: Bot ${DISCORD_TOKEN}" -X POST -H "Content-Type: application/json" -d '{"content": "Deploying new version of the bot...\n'"$msg\"}" | |
- name: Fetch the binary | |
uses: actions/download-artifact@v2 | |
with: | |
name: neomason-bin | |
- name: Deploy the binary | |
env: | |
SSH_KEY: ${{ secrets.SSH_KEY }} | |
run: | | |
eval $(ssh-agent -s) | |
ssh-agent bash | |
ssh-add <(echo "$SSH_KEY") | |
mkdir ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config | |
ssh-add -l | |
rsync neomason-discord-bot [email protected]:neomason-current | |
ssh [email protected] "sudo /bin/systemctl restart neomason-discord-bot" |