Last active
March 4, 2022 16:23
-
-
Save Chadyka/03f8bca2c0fe27d3f0d76dd518d94d02 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| on: | |
| push: | |
| branches: | |
| - <branch_name> | |
| jobs: | |
| build_and_push: | |
| name: Build and push Docker image to DO Container Registry | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout master | |
| uses: actions/checkout@master | |
| - name: Build container image latest version | |
| run: docker build -t <docker_container_tag> . | |
| - name: Install doctl | |
| uses: digitalocean/action-doctl@v2 | |
| with: | |
| token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
| - name: Log in to DigitalOcean Container Registry with short-lived credentials | |
| run: doctl registry login --expiry-seconds 600 | |
| - name: Push image to DigitalOcean Container Registry | |
| run: docker push <docker_container_tag>:latest | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build_and_push | |
| steps: | |
| - name: Deploy to Digital Ocean droplet via SSH action | |
| uses: appleboy/ssh-action@v0.1.3 | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: ${{ secrets.USERNAME }} | |
| key: ${{ secrets.DO_SSH_KEY }} # Only ssh private key from local machine | |
| port: 22 | |
| script: | | |
| cd Apps/<container_dir> | |
| docker-compose stop <container_tag> | |
| docker-compose rm -f <container_tag> | |
| docker-compose pull <container_tag> | |
| docker-compose up -d <container_tag> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment