diff options
author | BuckarooBanzay <BuckarooBanzay@users.noreply.github.com> | 2022-12-23 14:31:24 +0100 |
---|---|---|
committer | BuckarooBanzay <BuckarooBanzay@users.noreply.github.com> | 2022-12-23 14:31:24 +0100 |
commit | 4dcf2ed647235afaeb1826a024d76463aa62dc65 (patch) | |
tree | 8f1bb610da6e0a71533e2760419ff7178ec84876 | |
parent | 03d0a15a9b805625bd8837dbb4eae78af574ce35 (diff) | |
download | hydra-dragonfire-4dcf2ed647235afaeb1826a024d76463aa62dc65.tar.xz |
docker build and workflow
-rw-r--r-- | .github/workflows/build.yml | 59 | ||||
-rw-r--r-- | .github/workflows/test.yml | 27 | ||||
-rw-r--r-- | Dockerfile | 9 |
3 files changed, 95 insertions, 0 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c81f29a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,59 @@ +name: build + +on: + push: + branches: + - 'master' + tags: + - 'v*' + pull_request: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + + - name: Set up Go + uses: actions/setup-go@v3.4.0 + with: + go-version: 1.18 + + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image (master) + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}
\ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..21791d3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: test + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: 1.18.x + + - name: Test + run: | + go test ./... -coverprofile=profile.cov + + - uses: shogo82148/actions-goveralls@v1.6.0 + with: + path-to-profile: profile.cov
\ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c568c0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM golang:1.18.9 as builder +WORKDIR /app +COPY . . +RUN go test ./... &&\ + CGO_ENABLED=0 go build . + +FROM scratch +COPY --from=builder /app/hydra-dragonfire /bin/hydra-dragonfire +ENTRYPOINT ["/bin/hydra-dragonfire"] |