Skip to content

Deploy to VM

Deploy to VM #5

Workflow file for this run

name: Deploy to VM
on:
push:
branches:
- prod
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: chofnar/go-release-bot:${{ github.sha }}
- name: Deploy to VM
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
sudo docker pull chofnar/go-release-bot:${{ github.sha }}
sudo docker stop release-bot || true
sudo docker rm release-bot || true
sudo docker run -d --name release-bot -p 8443:8443 \
-e TELEGRAM_BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }} \
-e TELEGRAM_BOT_SITE_URL=${{ secrets.TELEGRAM_BOT_SITE_URL }} \
-e BOT_DYNAMODB_ENDPOINT=${{ secrets.BOT_DYNAMODB_ENDPOINT }} \
-e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
-e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
-e AWS_DEFAULT_REGION=${{ secrets.AWS_DEFAULT_REGION }} \
-e GITHUB_GQL_TOKEN=${{ secrets.GITHUB_GQL_TOKEN }} \
-e SUPER_SECRET_TOKEN=${{ secrets.SUPER_SECRET_TOKEN }} \
-e LIMIT=${{ secrets.LIMIT }} \
-e RESET_WEBHOOK_URL=${{ secrets.RESET_WEBHOOK_URL }} \
chofnar/go-release-bot:${{ github.sha }}