Skip to content

Commit

Permalink
Migrate to ghcr and public ecr (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaspawnW committed Mar 19, 2023
1 parent 9ab9940 commit 126dee8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
39 changes: 21 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
48 changes: 20 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
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"
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down

0 comments on commit 126dee8

Please sign in to comment.