From 126dee8d2b6f946adc65f21b863809efe12d09ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Wenzel?= Date: Sun, 19 Mar 2023 17:39:31 +0100 Subject: [PATCH] Migrate to ghcr and public ecr (#11) --- .github/workflows/release.yml | 39 +++++++++++++++------------- .github/workflows/test.yml | 48 +++++++++++++++-------------------- readme.md | 5 ++++ 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c361eb5..ee6e240 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,20 +9,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v4 with: go-version: 1.19.x - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Get tag version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - name: Build Asset (linux) - run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-linux-amd64 ./cmd/prometheus-aws-discovery/... + run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-linux-amd64 ./cmd/prometheus-aws-discovery/... - name: Build Asset (darwin) - run: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-darwin-amd64 ./cmd/prometheus-aws-discovery/... + run: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-darwin-amd64 ./cmd/prometheus-aws-discovery/... - name: Create Release id: create_release @@ -58,29 +58,32 @@ jobs: asset_content_type: application/x-mach-binary docker: - name: Docker Build - + name: Docker Push (GHCR & public ECR) runs-on: ubuntu-latest - + permissions: + id-token: write + contents: read + packages: write + needs: Release steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - 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: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - name: Set output id: vars run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 + - name: Docker publish + uses: daspawnw/docker-multi-build-push-action@master with: - push: true - tags: daspawnw/prometheus-aws-discovery:${{ steps.vars.outputs.tag }} + docker-tag: "${{ steps.vars.outputs.tag }}" + ghcr-enabled: "true" + ghcr-token: "${{ secrets.GITHUB_TOKEN }}" + ecr-enabled: "true" + ecr-role-to-assume: "${{ secrets.AWS_PUBLIC_ECR_ARN }}" + ecr-repository-url: "public.ecr.aws/l2l6k4u5/prometheus-aws-discovery" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06ac627..f835b98 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,25 +8,14 @@ jobs: runs-on: ${{ matrix.platform }} steps: - name: Install Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v4 with: go-version: 1.19.x - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Test run: go test ./... - sonarqube: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - coverage: runs-on: ubuntu-latest steps: @@ -35,7 +24,7 @@ jobs: with: go-version: 1.19.x - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Calculate coverage run: go test -covermode=count -coverprofile=coverage.out ./... - name: Convert coverage to lcov @@ -51,27 +40,30 @@ jobs: docker: name: Docker Build - runs-on: ubuntu-latest - - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/docker-') needs: test + permissions: + id-token: write + contents: read + packages: write steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - 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: Set output + id: vars + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 + - name: Docker publish + uses: daspawnw/docker-multi-build-push-action@master with: - push: true - tags: daspawnw/prometheus-aws-discovery:latest \ No newline at end of file + docker-tag: "${{ steps.vars.outputs.tag }}" + ghcr-enabled: "true" + ghcr-token: "${{ secrets.GITHUB_TOKEN }}" + ecr-enabled: "true" + ecr-role-to-assume: "${{ secrets.AWS_PUBLIC_ECR_ARN }}" + ecr-repository-url: "public.ecr.aws/l2l6k4u5/prometheus-aws-discovery" \ No newline at end of file diff --git a/readme.md b/readme.md index 575442c..56c025a 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,11 @@ Prometheus AWS/Azure Discovery provides a more flexible way to discover exporters running on ec2 instances or withing VMSS Instances (Azure VMs currently not covered by binary). +### Note! + +Due to Docker's decision to discontinue its Free Teams, I decided to host my Docker images on GHCR (GitHub Container +Registry) and public ECR (Elastic Container Registry) in the future. + ### AUTH AWS Auth is done via the AWS go sdk. Meaning it shoud support ENV Vars & Instance Profiles by default [AWS Docs](https://docs.aws.amazon.com/sdk-for-go/api/aws/session/)