Skip to content

CD for Dev

CD for Dev #1

Workflow file for this run

# .github/workflows/dev-cd.yml
name: CD for Dev
on:
workflow_run:
workflows: ["CI for Dev"]
types:
- completed
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Docker Hub
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile-dev
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO_DEV }}
- name: Deploy to Dev
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST_DEV }}
username: ${{ secrets.EC2_USERNAME_DEV }}
key: ${{ secrets.EC2_PRIVATE_KEY_DEV }}
port: 22
script: |
sudo docker rm -f $(docker ps -qa) || true
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO_DEV }}
docker-compose up -d
docker image prune -f