redeployment #24
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: redeployment | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set environment variables | |
env: | |
BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
PREFIX: ${{ secrets.PREFIX }} | |
SOUNDCLOUD_API_KEY: ${{ secrets.SOUNDCLOUD_API_KEY }} | |
CLIENT_ID: ${{ secrets.CLIENT_ID }} | |
run: | | |
echo "BOT_TOKEN=${BOT_TOKEN}" >> .env | |
echo "PREFIX=${PREFIX}" >> .env | |
echo "SOUNDCLOUD_API_KEY=${SOUNDCLOUD_API_KEY}" >> .env | |
echo "CLIENT_ID=${CLIENT_ID}" >> .env | |
- name: Login to Docker Hub | |
run: | | |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }} | |
- name: Build and Push Docker Compose | |
run: | | |
docker-compose -f docker-compose.yml build | |
docker-compose -f docker-compose.yml push | |
deploy-server: | |
runs-on: ubuntu-latest | |
needs: [build_and_push] | |
steps: | |
# add necessary steps to SSH into the server and pull the Docker image | |
- name: SSH into server and pull Docker image | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
cd beatbuddybot | |
./run.sh |