From d4aa5283adec7c9ec91b5dc568a7a978c5363d95 Mon Sep 17 00:00:00 2001 From: Markus Blaschke Date: Mon, 16 Nov 2020 19:29:49 +0100 Subject: [PATCH] implement github actions - multiarch build - ci & release pipeline Signed-off-by: Markus Blaschke --- .github/workflows/ci-docker.yml | 14 ++++++++ .github/workflows/release-docker.yml | 51 ++++++++++++++++++++++++++++ Dockerfile | 1 + Makefile | 3 ++ README.md | 4 +-- 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci-docker.yml create mode 100644 .github/workflows/release-docker.yml diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml new file mode 100644 index 0000000..5f0d4ad --- /dev/null +++ b/.github/workflows/ci-docker.yml @@ -0,0 +1,14 @@ +name: "CI: docker build" + +on: [pull_request] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag webdevops/azure-metrics-exporter:$(date +%s) diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml new file mode 100644 index 0000000..2c729b7 --- /dev/null +++ b/.github/workflows/release-docker.yml @@ -0,0 +1,51 @@ +name: "Release: docker" + +on: + schedule: + - cron: '0 6 * * 1' + push: + branches: + - '**' + tags: + - '*.*.*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: webdevops/azure-metrics-exporter,quay.io/webdevops/azure-metrics-exporter + #tag-sha: true + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to Quay + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 4fc274b..cfe7f1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ RUN make dependencies # Compile COPY ./ /go/src/github.com/webdevops/azure-metrics-exporter +RUN make test RUN make lint RUN make build RUN ./azure-metrics-exporter --help diff --git a/Makefile b/Makefile index 0269d8a..f148b33 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,9 @@ image: build build-push-development: docker build -t webdevops/$(NAME):development . && docker push webdevops/$(NAME):development +test: + go test ./... + .PHONY: lint lint: $(GOLANGCI_LINT_BIN) # megacheck fails to respect build flags, causing compilation failure during linting. diff --git a/README.md b/README.md index 4bfcc1d..fce7818 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ Azure Insights metrics exporter =============================== [![license](https://img.shields.io/github/license/webdevops/azure-metrics-exporter.svg)](https://github.com/webdevops/azure-metrics-exporter/blob/master/LICENSE) -[![Docker](https://img.shields.io/docker/cloud/automated/webdevops/azure-metrics-exporter)](https://hub.docker.com/r/webdevops/azure-metrics-exporter/) -[![Docker Build Status](https://img.shields.io/docker/cloud/build/webdevops/azure-metrics-exporter)](https://hub.docker.com/r/webdevops/azure-metrics-exporter/) +[![DockerHub](https://img.shields.io/badge/DockerHub-webdevops%2Fazure--metrics--exporter-blue)](https://hub.docker.com/r/webdevops/azure-metrics-exporter/) +[![Quay.io](https://img.shields.io/badge/Quay.io-webdevops%2Fazure--metrics--exporter-blue)](https://quay.io/repository/webdevops/azure-metrics-exporter) Prometheus exporter for Azure Insights metrics (on demand). Supports metrics fetching from all resource with one scrape (automatic service discovery) and also supports dimensions.