fix: lowercase image tag #2
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: CI/CD - Push Image & Update Manifests | |
| on: | |
| push: | |
| branches: ["main"] | |
| paths-ignore: | |
| - manifests/** | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| outputs: | |
| tag: ${{ steps.meta.outputs.tag }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| # https://github.com/docker/setup-buildx-action | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # https://github.com/docker/login-action | |
| - name: Log into registry ${{ env.REGISTRY }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Define image metadata | |
| id: meta | |
| run: | | |
| REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
| echo "tag=${{ env.REGISTRY }}/$REPO:${{ github.sha }}" >> $GITHUB_OUTPUT | |
| # https://github.com/docker/build-push-action | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tag }} | |
| labels: | | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| # https://github.com/moby/buildkit#github-actions-cache-experimental | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| cd: | |
| needs: ci | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| # https://github.com/mikefarah/yq | |
| - name: Install yq | |
| run: | | |
| VERSION=v4.43.1 | |
| wget "https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_linux_amd64" -O /usr/local/bin/yq | |
| chmod +x /usr/local/bin/yq | |
| - name: Patch kubernetes manifest with image tag | |
| run: | | |
| IMAGE="${{ needs.ci.outputs.tag }}" | |
| echo "Patching image: $IMAGE" | |
| yq e '.spec.template.spec.containers[0].image = strenv(IMAGE)' -i manifests/deployment.yaml | |
| - name: Commit and push manifest update | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git commit -am "Update image to ${{ needs.ci.outputs.tag }}" || echo "No changes to commit" | |
| git push |