diff --git a/.github/workflows/after-merge-dependabot.yml b/.github/workflows/after-merge-dependabot.yml index b1805fa..0d9ce87 100644 --- a/.github/workflows/after-merge-dependabot.yml +++ b/.github/workflows/after-merge-dependabot.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Fetch dependabot metadata id: dependabot-metadata - uses: dependabot/fetch-metadata@v1.6.0 + uses: dependabot/fetch-metadata@v2.1.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 296ad1c..7dd5cb3 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -22,7 +22,7 @@ jobs: - name: set up go uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - name: cache go modules uses: actions/cache@v4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..66f3577 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,48 @@ +name: build-and-release + +on: + push: + branches: + - '!*' + tags: + - 'v[0-9].*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Compute docker tags + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v5 + with: + images: orangeopensource/credhub-exporter + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Publish to DockerHub + uses: docker/build-push-action@v5 + with: + push: true + tags: ${{ steps.docker_meta.outputs.tags }} + + - name: Create github release + id: create-github-release + if: success() && startsWith(github.ref, 'refs/tags/') + uses: actions/create-release@v1 + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + body: | + Resource image available: + ``` + ${{ steps.docker_meta.outputs.tags }} + ``` + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index a2008b0..c100e86 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -16,7 +16,7 @@ jobs: - name: set up go uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - name: cache go modules uses: actions/cache@v4 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c0df779 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Stage 1 +FROM golang:1.22 as builder +WORKDIR /go/src/app +COPY . . +RUN go mod tidy +RUN go mod vendor +RUN CGO_ENABLED=0 go build -o /go/bin/app/credhub_exporter -a -tags netgo -ldflags '-w -extldflags "-static"' + +# Stage 2 +FROM alpine:3.19 +RUN apk add --no-cache ca-certificates +COPY --from=builder /go/bin/app/credhub_exporter /bin/credhub_exporter +EXPOSE 9358 +ENTRYPOINT ["/bin/credhub_exporter"]