Merge pull request #279 from TheUpperPart/Feat/#274 #17
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: CD Workflow | |
on: | |
push: | |
branches: ["dev", "HotFix/**"] | |
jobs: | |
docker: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Docker Image Build | |
run: docker build -t ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} -f dockerfile.prod . | |
- name: Login DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PW }} | |
- name: DockerHub Push | |
run: docker push ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} | |
- name: EC2 Login | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST_NAME }} | |
username: ${{secrets.USER_NAME }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
script: | | |
docker-compose down | |
docker image prune | |
docker rm $(docker ps -a -q) | |
docker pull ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} | |
docker-compose up -d |