From 12831864c3661746120dc3e6fb6a9069143423c4 Mon Sep 17 00:00:00 2001 From: Tejas-24ytj Date: Mon, 14 Sep 2026 17:46:19 +0530 Subject: [PATCH] Added gh workflow for image push --- .github/workflows/artifacts.yaml | 12 ----- .github/workflows/ci.yaml | 3 -- .github/workflows/release.yaml | 79 ++++++++++++++++++++++++++------ 3 files changed, 66 insertions(+), 28 deletions(-) diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml index 3ef68c7a42..4f9363cd6a 100644 --- a/.github/workflows/artifacts.yaml +++ b/.github/workflows/artifacts.yaml @@ -10,11 +10,6 @@ on: default: false required: false type: boolean - secrets: - DOCKER_USERNAME: - required: true - DOCKER_PASSWORD: - required: true outputs: container-image-name: description: Container image name @@ -108,13 +103,6 @@ jobs: username: ${{ github.actor }} password: ${{ github.token }} - - name: Login to Docker Hub - uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - if: inputs.publish - - name: Build and push image id: build uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7a39701ed2..df677449bf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -178,9 +178,6 @@ jobs: uses: ./.github/workflows/artifacts.yaml with: publish: ${{ github.event_name == 'push' }} - secrets: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} permissions: attestations: write contents: read diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index dbf397cbbe..5ad8c307c7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,24 +1,77 @@ -name: Release +name: Build and publish on: + workflow_dispatch: push: - tags: [ "v[0-9]+.[0-9]+.[0-9]+" ] + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + - "v[0-9]+.[0-9]+.[0-9]+-hotfix.*" permissions: contents: read + packages: write + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: - artifacts: - name: Artifacts - uses: ./.github/workflows/artifacts.yaml - with: - publish: true - secrets: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + build: + name: Build + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + variant: + - alpine + - distroless permissions: - attestations: write contents: read packages: write - id-token: write - security-events: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - 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 the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + latest=false + tags: | + type=semver,pattern={{raw}},enable=${{ matrix.variant == 'alpine' }} + type=semver,pattern={{version}},enable=${{ matrix.variant == 'alpine' }} + type=semver,pattern={{raw}},suffix=-${{ matrix.variant }} + type=semver,pattern={{version}},suffix=-${{ matrix.variant }} + type=raw,value=${{ github.sha }},enable=${{ github.ref_type != 'tag' && matrix.variant == 'alpine' }} + type=raw,value=${{ github.sha }},suffix=-${{ matrix.variant }},enable=${{ github.ref_type != 'tag' }} + labels: | + org.opencontainers.image.documentation=https://dexidp.io/docs/ + + - name: Build and push image + uses: docker/build-push-action@v6 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + BASE_IMAGE=${{ matrix.variant }} + VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} + COMMIT_HASH=${{ github.sha }} + BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}