Skip to content

thats right... all at once #32

thats right... all at once

thats right... all at once #32

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Copy DotEnv to root
run: echo "${{ secrets.DOTENV }}" > .env
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "rust"
shared-key: "cache"
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- name: Generate Prisma
uses: actions-rs/cargo@v1
with:
command: prisma-release
args: db push
- name: Build app
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Build Dockerfile
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/oreobot:latest .
- name: Login to DockerHub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Push Dockerfile
run: docker push ${{ secrets.DOCKER_USERNAME }}/oreobot:latest
- name: Save private key
run: |
echo "${{ secrets.SSH_KEY }}" > ssh_key
chmod 600 ssh_key
- name: Kill docker container
continue-on-error: true
run: ssh -i ssh_key ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR docker kill oreobot
- name: Remove docker container
continue-on-error: true
run: ssh -i ssh_key ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR docker rm oreobot
- name: Pull latest version of the docker container
continue-on-error: true
run: ssh -i ssh_key ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR docker pull ${{ secrets.DOCKER_USERNAME }}/oreobot:latest
- name: Start the Discord Bot
continue-on-error: true
run: ssh -i ssh_key ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR docker run -d --name oreobot ${{ secrets.DOCKER_USERNAME }}/oreobot:latest