Skip to content

Commit

Permalink
Create build_deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ksamnole authored May 5, 2021
1 parent 21ea6fd commit 2d0b3b5
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish on Docker Hub and Deploy

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

workflow_dispatch:

jobs:
build_and_pub:
runs-on: [ubuntu-latest]
env:
LOGIN: ${{ secrets.DOCKER_LOGIN }}
NAME: ${{ secrets.DOCKER_NAME }}
steps:
- name: Login to docker.io
run: docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{secrets.DOCKER_PWD}}
- uses: actions/checkout@master
- name: Build image
run: docker build -t $LOGIN/$NAME .
- name: Push image to docker.io
run: docker push $LOGIN/$NAME
deploy:
needs: [build_and_pub]
runs-on: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Deployment
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
username: ${{ secrets.SSH_USERNAME }}
script: |
sudo docker-compose down
sudo docker-compose pull
sudo docker-compose up -d

0 comments on commit 2d0b3b5

Please sign in to comment.