From 75edd598b06e2ae13a429bb38a2f20d52f573338 Mon Sep 17 00:00:00 2001 From: Kai Reichart Date: Wed, 27 Nov 2024 13:05:39 +0100 Subject: [PATCH] added components --- .github/workflows/build-docker.yml | 30 +++++++++++++++++++++++ .github/workflows/build-go-test.yml | 8 +++++++ .github/workflows/build-go.yml | 37 +++++++++++++++++++++++++++++ README.md | 17 +++++++++++++ main.go | 7 ++++++ 5 files changed, 99 insertions(+) create mode 100644 .github/workflows/build-docker.yml create mode 100644 .github/workflows/build-go-test.yml create mode 100644 .github/workflows/build-go.yml create mode 100644 README.md create mode 100644 main.go diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 0000000..6f2ec12 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,30 @@ +name: Build Docker Container + +on: + workflow_call: + inputs: + source: + description: 'The source directory to build' + required: false + type: string + default: './' + tag: + description: 'The tag to apply to the built image' + required: true + type: string + +jobs: + build-go: + runs-on: docker + container: + image: docker:27.4.0-rc.2-dind-alpine3.20 + steps: + - name: Clone Repository + run: git clone https://wf:${{ github.token }}@{{ github.server_url }}/{{ github.repository_owner }}/{{ github.repository }}.git + - name: Check Out Branch + run: | + cd + git checkout + - name: Build Docker Container + run: | + docker build -t ${{ inputs.tag }} ${{ inputs.source }} diff --git a/.github/workflows/build-go-test.yml b/.github/workflows/build-go-test.yml new file mode 100644 index 0000000..d5d6dd3 --- /dev/null +++ b/.github/workflows/build-go-test.yml @@ -0,0 +1,8 @@ +on: [push] +jobs: + test_build: + uses: ./.github/workflows/build-go.yml + with: + go-version: '1.23' + source: './main.go' + target: './dist/main' diff --git a/.github/workflows/build-go.yml b/.github/workflows/build-go.yml new file mode 100644 index 0000000..5bac187 --- /dev/null +++ b/.github/workflows/build-go.yml @@ -0,0 +1,37 @@ +name: Build Docker Container + +on: + workflow_call: + inputs: + source: + description: 'The source file to build' + required: false + type: string + default: './main.go' + target: + description: 'The output to store the build artifacts' + required: false + type: string + default: ./dist/main' + go-version: + description: 'The version of Go to use' + required: false + type: string + default: '>=1.23' + +jobs: + build-go: + runs-on: docker + container: + image: docker.io/node:20-bookworm + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ inputs.go-version }} + - name: Set up Go + run: | + go version + - name: Run go test + run: | + go build -o ${{ inputs.target }} ${{ inputs.source }} diff --git a/README.md b/README.md new file mode 100644 index 0000000..35e51f8 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# Pipeline Component - Build + +This component is responsible for building software artifacts. + +## Inputs + +| Name | Description | Default | Required | +|------|-------------|---------|:--------:| +| source | The source directory to build | `./` | false | +| target | The target directory to store the build artifacts | `./dist` | false | + +## Usage + +```yaml + + +``` diff --git a/main.go b/main.go new file mode 100644 index 0000000..a3dd973 --- /dev/null +++ b/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello, World!") +}