name: Build and Deploy Next.js + Nginx Docker Image on: push: branches: - main env: REGISTRY: ${{ secrets.REGISTRY_URL }} TAG: v${{ gitea.run_number }} REPO: ${{ gitea.repository }} IMAGE: ${{ secrets.REGISTRY_URL }}/${{ gitea.repository }}:v${{ gitea.run_number }} jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout source uses: https://git.d.aiengines.ir/actions/checkout@v4 - name: Set up Docker Buildx uses: https://git.d.aiengines.ir/actions/setup-buildx-action@v3 - name: Log in to Docker registry uses: https://git.d.aiengines.ir/actions/login-action@v3 with: registry: ${{ secrets.REGISTRY_URL }} username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - name: Build and push Docker image uses: https://git.d.aiengines.ir/actions/build-push-action@v6 with: context: . push: true tags: | ${{ env.REGISTRY }}/${{ env.REPO }}:latest ${{ env.REGISTRY }}/${{ env.REPO }}:${{ env.TAG }} cache-from: type=gha cache-to: type=gha,mode=max deploy: runs-on: ubuntu-latest needs: build-and-deploy steps: - name: deploy on server uses: appleboy/ssh-action@v1 env: DRONE_SSH_RELEASE_URL: https://cdn.d.aiengines.ir/public/drone-ssh/releases DRONE_SSH_VERSION: 1.8.1 with: host: 192.168.130.25 username: bagher key: ${{ secrets.SSH_KEY }} script: | docker service update -d --image ${{ env.IMAGE }} --force --with-registry-auth generative_front