feat: Improved regenerating #329
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
| # ============================================== | |
| # PyrenzAI Pipeline | |
| # ============================================== | |
| # This pipeline automatically handles: | |
| # | |
| # Building of the Application: | |
| # - Uses Docker Buildx to build the latest image | |
| # - Supports semantic versioning via Git tags | |
| # - Caches Docker layers for faster builds | |
| # | |
| # Publishing Docker Images: | |
| # - Pushes both `latest` and tagged versions to Docker Hub | |
| # | |
| # Discord Notifications: | |
| # - Notifies on successful deploy with full metadata | |
| # - Alerts on failure with error step, time, and message | |
| # - Uses rich Discord embeds for clean UI/UX | |
| # | |
| # Trigger: | |
| # - Runs automatically on push to the `main` branch | |
| # | |
| # ============================================== | |
| name: PyrenzAI Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| env: | |
| IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/pyrenzai | |
| IMAGE_TAG_LATEST: latest | |
| jobs: | |
| PyrenzAI-Pipeline: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v3 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-docker-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-docker- | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to Docker Hub | |
| run: | | |
| echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin | |
| - name: Build and push Docker image | |
| run: | | |
| docker buildx build \ | |
| --cache-from=type=local,src=/tmp/.buildx-cache \ | |
| --cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max \ | |
| -t $IMAGE_NAME:$IMAGE_TAG_LATEST \ | |
| --push \ | |
| . | |
| rm -rf /tmp/.buildx-cache | |
| mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
| - name: Print Docker Image Link | |
| run: | | |
| echo "🚀 Image deployed at: https://hub.docker.com/r/$IMAGE_NAME:$IMAGE_TAG_LATEST" | |
| - name: Send Discord notification on success | |
| if: success() | |
| run: | | |
| echo "Sending Discord success embed..." | |
| TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| DOCKER_USER="${{ secrets.DOCKERHUB_USERNAME }}" | |
| REPO="$IMAGE_NAME" | |
| TAG="$IMAGE_TAG_LATEST" | |
| URL="https://hub.docker.com/r/$IMAGE_NAME:$TAG" | |
| PAYLOAD=$(jq -n \ | |
| --arg ts "$TIMESTAMP" \ | |
| --arg user "$DOCKER_USER" \ | |
| --arg repo "$REPO" \ | |
| --arg tag "$TAG" \ | |
| --arg url "$URL" \ | |
| '{ | |
| embeds: [ | |
| { | |
| title: "✅ PyrenzAI Docker Deploy Successful", | |
| color: 5763719, | |
| fields: [ | |
| { name: "Time", value: $ts, inline: false }, | |
| { name: "Publisher", value: $user, inline: true }, | |
| { name: "Version", value: $tag, inline: true }, | |
| { name: "Docker Image", value: $url, inline: false } | |
| ], | |
| footer: { text: "PyrenzAI CI" }, | |
| timestamp: $ts | |
| } | |
| ] | |
| }') | |
| curl -H "Content-Type: application/json" \ | |
| -X POST \ | |
| -d "$PAYLOAD" \ | |
| ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| - name: Send Discord notification on failure | |
| if: failure() | |
| run: | | |
| echo "Sending Discord error embed..." | |
| TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| DOCKER_USER="${{ secrets.DOCKERHUB_USERNAME }}" | |
| REPO="$IMAGE_NAME" | |
| BUILD_STEP="${{ github.job }}" | |
| ERROR_MSG="Deployment failed on job $BUILD_STEP." | |
| TAG="$IMAGE_TAG_LATEST" | |
| PAYLOAD=$(jq -n \ | |
| --arg ts "$TIMESTAMP" \ | |
| --arg user "$DOCKER_USER" \ | |
| --arg repo "$REPO" \ | |
| --arg step "$BUILD_STEP" \ | |
| --arg err "$ERROR_MSG" \ | |
| --arg ver "$TAG" \ | |
| '{ | |
| embeds: [ | |
| { | |
| title: "🚨 ERROR ON DEPLOYMENT", | |
| color: 15158332, | |
| fields: [ | |
| { name: "Time", value: $ts, inline: false }, | |
| { name: "Publisher", value: $user, inline: true }, | |
| { name: "Repo", value: $repo, inline: true }, | |
| { name: "Build Step", value: $step, inline: false }, | |
| { name: "Version", value: $ver, inline: true }, | |
| { name: "Error Message", value: $err, inline: false } | |
| ], | |
| footer: { text: "PyrenzAI CI" }, | |
| timestamp: $ts | |
| } | |
| ] | |
| }') | |
| curl -H "Content-Type: application/json" \ | |
| -X POST \ | |
| -d "$PAYLOAD" \ | |
| ${{ secrets.DISCORD_WEBHOOK_URL }} |