From 15dfef63197d5b0bdfbb7905158057f6b43bfaa2 Mon Sep 17 00:00:00 2001 From: Mmadu Manasseh Date: Mon, 25 Jan 2021 01:14:24 +0100 Subject: [PATCH] CI: Use goreleaser to deploy to dockerhub --- .../{goreleaser.yml => deploy-and-release.yml} | 16 +++++++++++++--- .github/workflows/docker-release.yml | 18 ------------------ .goreleaser.yml | 11 ++++++++++- Dockerfile | 14 ++++++-------- README.md | 7 ++++--- 5 files changed, 33 insertions(+), 33 deletions(-) rename .github/workflows/{goreleaser.yml => deploy-and-release.yml} (51%) delete mode 100644 .github/workflows/docker-release.yml diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/deploy-and-release.yml similarity index 51% rename from .github/workflows/goreleaser.yml rename to .github/workflows/deploy-and-release.yml index 4a51961..4f5ea14 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/deploy-and-release.yml @@ -1,8 +1,8 @@ -name: goreleaser -on: +name: deploy +on: push: tags: - - '*' + - 'v*' jobs: goreleaser: @@ -18,6 +18,14 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.15 + - + name: Docker Login + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 @@ -26,3 +34,5 @@ jobs: args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml deleted file mode 100644 index 53c78d2..0000000 --- a/.github/workflows/docker-release.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Publish Docker image -on: - release: - types: [published] -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - name: Push to Docker Hub - uses: docker/build-push-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - repository: mensaah/reka - tag_with_ref: true \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 375d670..2dfd0b5 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -16,6 +16,15 @@ builds: - goos: darwin goarch: 386 +dockers: + - image_templates: + - mensaah/{{.ProjectName}} + goos: linux + goarch: amd64 + goarm: '' + dockerfile: Dockerfile + skip_push: false + archives: - name_template: "{{.Binary}}_{{.Os}}_{{.Arch}}" format_overrides: @@ -26,4 +35,4 @@ archives: linux: Linux windows: Windows 386: i386 - amd64: x86_64 \ No newline at end of file + amd64: x86_64 diff --git a/Dockerfile b/Dockerfile index f9540e1..1a9761b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,8 @@ -FROM golang:1.15 AS builder -RUN apk update && apk add --no-cache git -WORKDIR $GOPATH/src/github/mensaah/reka/ -COPY . . -RUN go get -v -RUN go build -o /go/bin/reka +# Builder image so to add ca-certificates to scratch +FROM golang:alpine as build +RUN apk add -U --no-cache ca-certificates FROM scratch -COPY --from=builder /go/bin/reka /go/bin/reka -ENTRYPOINT ["/go/bin/reka"] \ No newline at end of file +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY reka / +ENTRYPOINT ["/reka"] \ No newline at end of file diff --git a/README.md b/README.md index b25adee..f775eab 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@
[![Build Status](https://github.com/mensaah/reka/workflows/Test/badge.svg)](https://github.com/mensaah/reka/actions) +[![deploy](https://github.com/MeNsaaH/reka/workflows/deploy/badge.svg)](https://github.com/mensaah/reka/actions) A Cloud Infrastructure Management Tool to stop, resume, clean and destroy resources based on tags. Reka uses a config to determine what actions should be taken on resources. It can prove to be a cost management tool where you can stop your tests environments during breaks, holidays and non-working hours. It can also be a nuke tool to nuke an account. It currently supports both AWS and GCP. A full list of supported resources can be found [here](./docs/supported-resources.md) @@ -13,7 +14,7 @@ A Cloud Infrastructure Management Tool to stop, resume, clean and destroy resour - Destroy/Terminate resources - Clean Up unused resources (such as EBS volumes, Elastic IPs) -### Project Name +#### Project Name `REKA` is derived from a Native Nigerian Language, Igbo, meaning `Reap`|`Tear Down`. ### BEWARE! @@ -48,8 +49,8 @@ The reka image is also available on DockerHub. If `config.yaml` is in the current directory, reka can be executed as: ```bash - docker -it -e AWS_ACCESS_KEY -e AWS_SECRET_ACCESS_KEY\ - -v `pwd`:/config run mensaah/reka --config /config/config.yaml + docker run -it -e AWS_ACCESS_KEY -e AWS_SECRET_ACCESS_KEY\ + -v `pwd`:/config mensaah/reka --config /config/config.yaml ``` #### Go