ADD: get drivers or constructor championship decider in a circuit #10
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: Build and Deploy | |
| on: | |
| push: | |
| branches: [master] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Normalize repo name to lowercase | |
| run: | | |
| OWNER_LOWER=$(echo "${GITHUB_REPOSITORY%/*}" | tr '[:upper:]' '[:lower:]') | |
| REPO_LOWER=$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]') | |
| echo "OWNER_LOWER=$OWNER_LOWER" >> $GITHUB_ENV | |
| echo "REPO_LOWER=$REPO_LOWER" >> $GITHUB_ENV | |
| echo "IMAGE=ghcr.io/$OWNER_LOWER/$REPO_LOWER" >> $GITHUB_ENV | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ env.IMAGE }}:latest | |
| ${{ env.IMAGE }}:${{ github.sha }} | |
| - name: Deploy to Dokploy via API | |
| if: success() | |
| run: | | |
| echo "🚀 Deploying to Dokploy..." | |
| RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ | |
| "${{ secrets.DOKPLOY_DEPLOY_URL }}" \ | |
| -H "accept: application/json" \ | |
| -H "Content-Type: application/json" \ | |
| -H "x-api-key: ${{ secrets.DOKPLOY_API_TOKEN }}" \ | |
| -H "CF-Access-Client-Id: ${{ secrets.CF_ACCESS_CLIENT_ID }}" \ | |
| -H "CF-Access-Client-Secret: ${{ secrets.CF_ACCESS_CLIENT_SECRET }}" \ | |
| -d "{\"applicationId\": \"${{ secrets.DOKPLOY_APPLICATION_ID }}\"}") | |
| HTTP_CODE=$(echo "$RESPONSE" | tail -n1) | |
| BODY=$(echo "$RESPONSE" | sed '$d') | |
| echo "Response code: $HTTP_CODE" | |
| echo "Response body: $BODY" | |
| if [ $HTTP_CODE -eq 200 ] || [ $HTTP_CODE -eq 201 ] || [ $HTTP_CODE -eq 204 ]; then | |
| echo "✅ Deployment triggered successfully!" | |
| else | |
| echo "❌ Deployment failed with status code: $HTTP_CODE" | |
| exit 1 | |
| fi |