adding scripts #2
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 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build Docker image | |
run: docker build -t your_dockerhub_username/your_app_name . | |
- name: Log in to Docker Hub | |
run: echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin | |
- name: Push Docker image | |
run: docker push your_dockerhub_username/your_app_name | |
- name: Deploy to DigitalOcean | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ secrets.DO_SSH_USER }}@${{ secrets.DO_IP_ADDRESS }} << 'EOF' | |
docker pull your_dockerhub_username/your_app_name | |
docker stop your_app_container || true | |
docker rm your_app_container || true | |
docker run -d -p 80:3000 --name your_app_container your_dockerhub_username/your_app_name | |
EOF |