diff --git a/.gitea/workflows/ci-cd.yaml b/.gitea/workflows/ci-cd.yaml index 1455c79..c3fb505 100644 --- a/.gitea/workflows/ci-cd.yaml +++ b/.gitea/workflows/ci-cd.yaml @@ -9,36 +9,29 @@ jobs: name: Build & Deploy runs-on: ubuntu-latest steps: - - name: Clone repo + - name: Checkout code run: | - git clone --depth=1 --branch=main https://gitlab.impresion3d.pro/root/davidaragon-portfolio.git repo - cd repo && ls -la + git clone https://oauth2:${{ secrets.GITEA_TOKEN }}@gitlab.impresion3d.pro/root/davidaragon-portfolio.git repo + cd repo && git log -1 --oneline - - name: Build image with docker + - name: Build and push image run: | cd repo - docker build -t gitlab.impresion3d.pro/root/davidaragon-portfolio:latest . - - - name: Login to registry - run: | echo "${{ secrets.DOCKER_PASSWORD }}" | docker login gitlab.impresion3d.pro -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - - - name: Push image - run: | + docker build -t gitlab.impresion3d.pro/root/davidaragon-portfolio:latest . docker push gitlab.impresion3d.pro/root/davidaragon-portfolio:latest - - name: Stop Portainer stack + - name: Deploy to Portainer run: | + # Stop stack 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: | + + # Pull fresh image 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: | + + # Start stack 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 }}"