name: CI/CD Pipeline on: push: branches: [main] jobs: deploy: name: Build & Deploy runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver-opts: image=moby/buildkit:v0.12.5 - name: Login to registry uses: docker/login-action@v3 with: registry: gitlab.impresion3d.pro username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push image uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile platforms: linux/amd64 push: true tags: | gitlab.impresion3d.pro/root/davidaragon-portfolio:latest - name: Stop Portainer stack run: | curl -X POST "${{ secrets.PORTAINER_URL }}/api/stacks/${{ secrets.PORTAINER_STACK_ID }}/stop?endpointId=${{ secrets.PORTAINER_ENDPOINT_ID }}" \ -H "X-API-Key: ${{ secrets.PORTAINER_TOKEN }}" sleep 5 - name: Pull fresh image run: | curl -X POST "${{ secrets.PORTAINER_URL }}/api/endpoints/${{ secrets.PORTAINER_ENDPOINT_ID }}/docker/images/create?fromImage=gitlab.impresion3d.pro%2Froot%2Fdavidaragon-portfolio&tag=latest" \ -H "X-API-Key: ${{ secrets.PORTAINER_TOKEN }}" - name: Start Portainer stack run: | curl -X POST "${{ secrets.PORTAINER_URL }}/api/stacks/${{ secrets.PORTAINER_STACK_ID }}/start?endpointId=${{ secrets.PORTAINER_ENDPOINT_ID }}" \ -H "X-API-Key: ${{ secrets.PORTAINER_TOKEN }}"