π cicd: yml μμ #1
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
| name: Dev CI/CD | |
| on: | |
| push: | |
| branches: [ "develop" ] | |
| jobs: | |
| build_and_push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build & Push image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| agigora/dogcat:dev | |
| agigora/dogcat:${{ github.sha }} | |
| platforms: linux/amd64 | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build_and_push | |
| steps: | |
| - name: SSH & Deploy | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| script_stop: true | |
| script: | | |
| set -euxo pipefail | |
| cd ~/dogcat | |
| echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "agigora" --password-stdin | |
| docker compose -f docker-compose-dev.yml --env-file .env.dev pull | |
| docker compose -f docker-compose-dev.yml --env-file .env.dev up -d | |
| docker image prune -f |