From 70b0bd97d30f70da4a1b34d11c02aa93fc385176 Mon Sep 17 00:00:00 2001 From: andreaTP Date: Fri, 11 Mar 2022 12:40:39 +0000 Subject: [PATCH] GH Action to release the container image --- .github/workflows/container.yml | 36 ------------------- .github/workflows/release-container.yml | 48 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 36 deletions(-) delete mode 100644 .github/workflows/container.yml create mode 100644 .github/workflows/release-container.yml diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml deleted file mode 100644 index b68f90c5d..000000000 --- a/.github/workflows/container.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Container -on: - push: - paths-ignore: - - '**.md' - - '**.asciidoc' - pull_request: - paths-ignore: - - '**.md' - - '**.asciidoc' - types: - - opened - - synchronize -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - id: repository - uses: ASzc/change-string-case-action@v1 - with: - string: ${{ github.repository }} - - - name: Build and push container images - uses: docker/build-push-action@v1 - with: - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_PASSWORD }} - repository: ${{ steps.repository.outputs.lowercase }} - registry: quay.io - tag_with_ref: true - always_pull: true - push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} diff --git a/.github/workflows/release-container.yml b/.github/workflows/release-container.yml new file mode 100644 index 000000000..b57a534f3 --- /dev/null +++ b/.github/workflows/release-container.yml @@ -0,0 +1,48 @@ + name: Release Keycloak Operator container + + on: + workflow_dispatch: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + concurrency: keycloak-operator-container-release + + jobs: + publish: + if: github.repository == 'keycloak/keycloak-operator' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Container metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: quay.io/keycloak/keycloak-operator + flavor: | + latest=false + tags: | + type=ref,event=branch + type=raw,value=legacy + type=semver,pattern={{version}}-legacy + type=semver,pattern={{major}}.{{minor}}-legacy + + - name: Login to Quay + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}