Repository navigation
fix: use GNU sed for Linux + add AI agent best practices to AGENTS.md #4
Workflow file for this run
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: Update and Build ralphex-fe | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| bun_version: | ||
| description: 'New Bun version to set in Dockerfile (e.g., 1.4.0)' | ||
| required: true | ||
| type: string | ||
| hugo_version: | ||
| description: 'New Hugo version to set in Dockerfile (e.g., 0.156.0)' | ||
| required: true | ||
| type: string | ||
| update_only: | ||
| description: 'Only update Dockerfile without building image' | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ralphex-fe | ||
| DOCKERFILE_PATH: ralphex-fe/Dockerfile | ||
| jobs: | ||
| update-dockerfile: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| outputs: | ||
| versions_updated: ${{ steps.update.outputs.updated }} | ||
| bun_version: ${{ steps.update.outputs.bun_version }} | ||
| hugo_version: ${{ steps.update.outputs.hugo_version }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Update Dockerfile versions | ||
| id: update | ||
| env: | ||
| INPUT_BUN_VERSION: ${{ inputs.bun_version }} | ||
| INPUT_HUGO_VERSION: ${{ inputs.hugo_version }} | ||
| run: | | ||
| # Read current versions | ||
| CURRENT_BUN=$(grep '^ARG BUN_VERSION=' "${{ env.DOCKERFILE_PATH }}" | cut -d'=' -f2) | ||
| CURRENT_HUGO=$(grep '^ARG HUGO_VERSION=' "${{ env.DOCKERFILE_PATH }}" | cut -d'=' -f2) | ||
| echo "Current versions:" | ||
| echo " Bun: $CURRENT_BUN" | ||
| echo " Hugo: $CURRENT_HUGO" | ||
| echo "" | ||
| echo "Requested versions:" | ||
| echo " Bun: $INPUT_BUN_VERSION" | ||
| echo " Hugo: $INPUT_HUGO_VERSION" | ||
| # Update Bun version (GNU sed syntax for Linux) | ||
| sed -i "s/^ARG BUN_VERSION=.*/ARG BUN_VERSION=$INPUT_BUN_VERSION/" "${{ env.DOCKERFILE_PATH }}" | ||
| # Update Hugo version (GNU sed syntax for Linux) | ||
| sed -i "s/^ARG HUGO_VERSION=.*/ARG HUGO_VERSION=$INPUT_HUGO_VERSION/" "${{ env.DOCKERFILE_PATH }}" | ||
| # Verify changes | ||
| echo "" | ||
| echo "Updated versions in Dockerfile:" | ||
| grep '^ARG BUN_VERSION=' "${{ env.DOCKERFILE_PATH }}" | ||
| grep '^ARG HUGO_VERSION=' "${{ env.DOCKERFILE_PATH }}" | ||
| # Check if anything changed | ||
| if git diff --quiet "${{ env.DOCKERFILE_PATH }}"; then | ||
| echo "No changes detected - versions are already up to date" | ||
| echo "updated=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "Changes detected - versions updated" | ||
| echo "updated=true" >> $GITHUB_OUTPUT | ||
| fi | ||
| echo "bun_version=$INPUT_BUN_VERSION" >> $GITHUB_OUTPUT | ||
| echo "hugo_version=$INPUT_HUGO_VERSION" >> $GITHUB_OUTPUT | ||
| - name: Commit and push changes | ||
| if: steps.update.outputs.updated == 'true' | ||
| env: | ||
| BUN_VERSION: ${{ steps.update.outputs.bun_version }} | ||
| HUGO_VERSION: ${{ steps.update.outputs.hugo_version }} | ||
| GITHUB_ACTOR: ${{ github.actor }} | ||
| ACTOR_ID: ${{ github.actor_id }} | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add "${{ env.DOCKERFILE_PATH }}" | ||
| # Create commit message | ||
| git commit -m "chore(ralphex-fe): update versions to Bun ${BUN_VERSION}, Hugo ${HUGO_VERSION} | ||
| Updated via GitHub Actions workflow dispatch. | ||
| Co-Authored-By: ${GITHUB_ACTOR} <${ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com>" | ||
| git push | ||
| echo "✅ Dockerfile updated and pushed to repository" | ||
| - name: No changes needed | ||
| if: steps.update.outputs.updated == 'false' | ||
| run: | | ||
| echo "ℹ️ Dockerfile already has the requested versions - no update needed" | ||
| build-and-push: | ||
| needs: update-dockerfile | ||
| if: ${{ needs.update-dockerfile.outputs.versions_updated == 'true' && inputs.update_only == false }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.ref }} | ||
| # Pull latest changes since we just pushed | ||
| - name: Pull latest changes | ||
| run: git pull | ||
| - name: Extract versions from updated Dockerfile | ||
| id: versions | ||
| run: | | ||
| BUN_VERSION=$(grep '^ARG BUN_VERSION=' "${{ env.DOCKERFILE_PATH }}" | cut -d'=' -f2) | ||
| HUGO_VERSION=$(grep '^ARG HUGO_VERSION=' "${{ env.DOCKERFILE_PATH }}" | cut -d'=' -f2) | ||
| echo "bun=$BUN_VERSION" >> $GITHUB_OUTPUT | ||
| echo "hugo=$HUGO_VERSION" >> $GITHUB_OUTPUT | ||
| echo "Building with versions:" | ||
| echo " Bun: $BUN_VERSION" | ||
| echo " Hugo: $HUGO_VERSION" | ||
| - name: Generate image tags | ||
| id: tags | ||
| env: | ||
| BUN_VERSION: ${{ steps.versions.outputs.bun }} | ||
| HUGO_VERSION: ${{ steps.versions.outputs.hugo }} | ||
| run: | | ||
| NAMESPACE=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') | ||
| BASE_IMAGE="${{ env.REGISTRY }}/${NAMESPACE}/${{ env.IMAGE_NAME }}" | ||
| VERSION_TAG="bun${BUN_VERSION}-hugo${HUGO_VERSION}-ralphex" | ||
| TAGS="${BASE_IMAGE}:latest,${BASE_IMAGE}:${VERSION_TAG}" | ||
| echo "namespace=$NAMESPACE" >> $GITHUB_OUTPUT | ||
| echo "tags=$TAGS" >> $GITHUB_OUTPUT | ||
| echo "Generated tags:" | ||
| echo "$TAGS" | tr ',' '\n' | ||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Log in to Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Extract metadata for Docker | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ steps.tags.outputs.namespace }}/${{ env.IMAGE_NAME }} | ||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: ralphex-fe | ||
| file: ${{ env.DOCKERFILE_PATH }} | ||
| platforms: linux/amd64,linux/arm64 | ||
| push: true | ||
| tags: ${{ steps.tags.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| - name: Verify image | ||
| env: | ||
| TAGS: ${{ steps.tags.outputs.tags }} | ||
| run: | | ||
| FIRST_TAG=$(echo "$TAGS" | cut -d',' -f1) | ||
| echo "Verifying multiplatform image: $FIRST_TAG" | ||
| docker pull --platform linux/amd64 "$FIRST_TAG" | ||
| docker pull --platform linux/arm64 "$FIRST_TAG" | ||
| echo "Verifying Bun installation (amd64)..." | ||
| docker run --rm --platform linux/amd64 "$FIRST_TAG" bun --version | ||
| echo "Verifying Hugo installation (amd64)..." | ||
| docker run --rm --platform linux/amd64 "$FIRST_TAG" hugo version | ||
| echo "Verifying Bun installation (arm64)..." | ||
| docker run --rm --platform linux/arm64 "$FIRST_TAG" bun --version | ||
| echo "Verifying Hugo installation (arm64)..." | ||
| docker run --rm --platform linux/arm64 "$FIRST_TAG" hugo version | ||
| echo "✅ Multiplatform image successfully built and pushed!" | ||
| echo "Tags: $TAGS" | ||