From 79e75738758223ddb4ac9264c9f1d4bd2cc858a1 Mon Sep 17 00:00:00 2001 From: max5dt <86766028+max5dt@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:20:03 +0200 Subject: [PATCH] Update and rename docker-build.yaml to docker-helm.yaml --- .github/workflows/docker-build.yaml | 36 ------------- .github/workflows/docker-helm.yaml | 79 +++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 36 deletions(-) delete mode 100644 .github/workflows/docker-build.yaml create mode 100644 .github/workflows/docker-helm.yaml diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml deleted file mode 100644 index 681c117..0000000 --- a/.github/workflows/docker-build.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: Build and Push Docker Image with Buildx. - -on: - push: - branches: - - master - - dev - pull_request: - branches: - - master - workflow_dispatch: - -jobs: - build: - runs-on: ${{ vars.RUNNER_SCALE_SET }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Login to Docker Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ${{ vars.DOCKER_REGISTRY }} - username: ${{ vars.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Set up Docker Buildx - if: github.event_name != 'pull_request' - uses: docker/setup-buildx-action@v3 - - - name: Build and push - uses: docker/build-push-action@v6 - with: - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ vars.DOCKER_REGISTRY }}/${{ vars.DOCKER_PROJECT }}/${{ vars.DOCKER_IMAGE }}:${{ github.sha }} diff --git a/.github/workflows/docker-helm.yaml b/.github/workflows/docker-helm.yaml new file mode 100644 index 0000000..1b24f72 --- /dev/null +++ b/.github/workflows/docker-helm.yaml @@ -0,0 +1,79 @@ +name: Build and Push Docker Image with Buildx and Push Helm Chart + +on: + push: + branches: + - main + - dev + tags: + - '*' + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + docker: + if: github.event_name != 'pull_request' + runs-on: ${{ vars.RUNNER_SCALE_SET }} + steps: + - name: Login to Docker Registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.DOCKER_REGISTRY }} + username: ${{ vars.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ vars.DOCKER_REGISTRY }}/${{ vars.DOCKER_PROJECT }}/${{ vars.DOCKER_IMAGE }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha,format=long,prefix= + type=sha,prefix= + charts: | + type=semver,pattern={{version}} + + - name: Build and Push Docker image + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + helm: + if: github.ref_type == 'tag' + runs-on: ${{ vars.RUNNER_SCALE_SET }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + tags: | + type=semver,pattern={{version}} + flavor: | + latest=false + + - name: Install Helm + uses: azure/setup-helm@v4.2.0 + + - name: Push Helm Chart + uses: appany/helm-oci-chart-releaser@v0.3.0 + with: + name: ${{ vars.DOCKER_IMAGE }} + repository: charts + tag: ${{ steps.meta.outputs.tags }} + path: deploy/chart + registry: ${{ vars.DOCKER_REGISTRY }} + registry_username: ${{ vars.DOCKER_USERNAME }} + registry_password: ${{ secrets.DOCKER_PASSWORD }}