add message for easier debug #8
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: Build,Test and Deploy | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: | |
name: 'Production' | |
defaults: | |
run: | |
working-directory: . | |
steps: | |
- name: Checkout Source Code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
build-docker-image: | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: . | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Build docker image | |
run: docker build -t ${{secrets.DOCKER_USERNAME}}/hyobot . | |
- name: Log into Docker and upload image | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
run: | | |
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin | |
docker push ${{secrets.DOCKER_USERNAME}}/hyobot | |
deploy: | |
needs: [ build, build-docker-image ] | |
environment: | |
name: 'Production' | |
runs-on: ubuntu-latest | |
steps: | |
- name: SSH into VPS, pull docker image and run the image | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.PROD_SSH_HOST }} | |
username: ${{ secrets.PROD_SSH_USER }} | |
password: ${{ secrets.VPS_PASSWORD }} | |
script: | | |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
docker stop HyoBot | |
docker rm HyoBot | |
docker pull ${{ secrets.DOCKER_USERNAME }}/hyobot:latest | |
docker run -d --restart=always --name HyoBot --env-file ${{ secrets.SECRET_PATH }} ${{ secrets.DOCKER_USERNAME }}/hyobot:latest | |