From 234f06dcd7fd1c1bcf91a81173a129d5ad1efa50 Mon Sep 17 00:00:00 2001 From: Parham Alvani Date: Mon, 4 Dec 2023 11:17:02 +0000 Subject: [PATCH] feat: update configuration --- .github/dependabot.yml | 15 +++++++++ .github/workflows/ci.yaml | 52 +++++++++++++++--------------- .github/workflows/helm.yaml | 58 ++++++++++++++++++++++++++++++++++ build/package/docker-bake.json | 22 +++++++++++++ 4 files changed, 120 insertions(+), 27 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/helm.yaml create mode 100644 build/package/docker-bake.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3198c0f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 277e616..34d8793 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,5 +1,5 @@ --- -name: ci +name: test on: - push jobs: @@ -7,54 +7,52 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: "1.21" - name: golangci-lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: version: latest + args: --enable-all --timeout=30m + test: name: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 with: - go-version: 1.21 - - run: docker-compose up -d + go-version: "1.21" - run: go test -v ./... -covermode=atomic -coverprofile=coverage.out - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v3.1.4 with: files: coverage.out docker: - name: docker runs-on: ubuntu-latest needs: - lint - test + if: github.event_name != 'pull_request' steps: - - uses: actions/checkout@v2 - - uses: docker/setup-qemu-action@v1 - - uses: docker/setup-buildx-action@v1 - - uses: docker/login-action@v1 + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/metadata-action@v3 - id: meta + - uses: docker/bake-action@v4 + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + env: + TAG: ${{ github.ref_name }} with: - images: ghcr.io/snapp-incubator/mqtt-blackbox-exporter - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - uses: docker/build-push-action@v2 + push: true + files: 'build/package/docker-bake.json' + - uses: docker/bake-action@v4 + if: ${{ !startsWith(github.ref, 'refs/tags/v') }} with: - file: "build/package/Dockerfile" - context: . - platforms: linux/amd64 push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + files: 'build/package/docker-bake.json' diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml new file mode 100644 index 0000000..8e0c8d4 --- /dev/null +++ b/.github/workflows/helm.yaml @@ -0,0 +1,58 @@ +--- +name: helm +on: + - push + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: set up helm + uses: azure/setup-helm@v3 + with: + version: v3.13.0 + + - uses: actions/setup-python@v4 + with: + python-version: 3.7 + + - name: set up chart-testing + uses: helm/chart-testing-action@v2.6.1 + + - name: run chart-testing (lint) + run: ct lint --all + + - name: create kind cluster + uses: helm/kind-action@v1.8.0 + + - name: run chart-testing (install) + run: ct install --all + + release: + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: set up helm + uses: azure/setup-helm@v3 + with: + version: v3.13.0 + + - name: login to github container registry using helm + run: | + echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io/snapp-incubator/mqtt-blackbox-exporter --username ${{ github.repository_owner }} --password-stdin + + - name: package mqtt-blackbox-exporter helm chart + run: | + version=${{ github.ref_name }} + helm package --version "${version##v}" --app-version "${version}" ./charts/mqtt-blackbox-exporter + + - name: publish mqtt-blackbox-exporter chart to github container registry + run: | + version=${{ github.ref_name }} + helm push "soteria-${version##v}".tgz oci://ghcr.io/snapp-incubator/mqtt-blackbox-exporter-chart diff --git a/build/package/docker-bake.json b/build/package/docker-bake.json new file mode 100644 index 0000000..4904f90 --- /dev/null +++ b/build/package/docker-bake.json @@ -0,0 +1,22 @@ +{ + "group": { + "default": { + "targets": [ + "soteria" + ] + } + }, + "variable": { + "TAG": { + "default": "latest" + } + }, + "target": { + "soteria": { + "dockerfile": "build/package/Dockerfile", + "tags": [ + "ghcr.io/snapp-incubator/mqtt-blackbox-exporter:${TAG}" + ] + } + } +}