fix rust-cache #29
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: 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: actions/cache@v3 | |
with: | |
path: | | |
/home/runner/.cargo | |
/home/runner/work/oreobot/oreobot/target | |
key: v0-rust-build-fb41acb8-b19632d7 | |
- 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 |