From bd777491ed0c67a12e86e893a690194df70a8718 Mon Sep 17 00:00:00 2001 From: Daniel Moch Date: Thu, 13 Jun 2024 13:03:37 -0400 Subject: [PATCH] add CI workflow --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ Dockerfile | 16 ++++++++++++++++ devtools/build_deployment.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 Dockerfile create mode 100644 devtools/build_deployment.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..00148fc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +# See LICENSE file for copyright and license information +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.x' + + - name: Setup go-task + uses: lukeshay/setup-task@v1 + + - name: Test + run: task ci diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c124c6c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# Copyright 2024 Daniel Moch, all rights reserved +FROM golang:1.21-alpine AS build + +RUN mkdir -p djmo.ch/dgit + +COPY ./ /djmo.ch/dgit/ + +RUN cd /djmo.ch/dgit/cmd/dgit && CGO_ENABLED=0 go build ./ + +FROM scratch + +COPY --from=build /djmo.ch/dgit/cmd/dgit/dgit /usr/local/bin/ + +CMD ["/usr/local/bin/dgit"] + +USER 1001 diff --git a/devtools/build_deployment.sh b/devtools/build_deployment.sh new file mode 100644 index 0000000..9c50221 --- /dev/null +++ b/devtools/build_deployment.sh @@ -0,0 +1,27 @@ +#!/bin/sh +set -eu + +# See LICENSE file for copyright and license details + +[ -d .git ] || { echo "not at repo root ... exiting"; exit 1; } + +usage() { + echo "usage: $0 BUILD_TAG" +} + +build() { + BUILD_TAG=$1 + docker build -t $BUILD_TAG . +} + +main() { + case "$1" in + "-h"|"--help"|"help") + usage + exit + ;; + *) + build + ;; + esac +}