From cd238e5415c61528a3c405887a2455571025a8cb Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Sun, 7 Jun 2020 13:02:39 +0100 Subject: [PATCH] Initial release --- Dockerfile | 11 +++++++++++ Makefile | 22 +--------------------- giteaPR.sh | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 giteaPR.sh diff --git a/Dockerfile b/Dockerfile index e69de29..a085899 100644 --- a/Dockerfile +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine + +RUN apk update && apk add curl + +ADD giteaPR.sh / +RUN chmod +x /giteaPR.sh + +ENV GITEA_HOST=git.cluster.fun +ENV ACCESS_KEY= + +ENTRYPOINT [ "/giteaPR.sh" ] diff --git a/Makefile b/Makefile index e5e5994..6166f77 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .DEFAULT_GOAL := default -IMAGE ?= docker.cluster.fun/private/gitea-pr-status:latest +IMAGE ?= docker.cluster.fun/averagemarcus/gitea-pr-status:latest .PHONY: test # Run all tests, linting and format checks test: lint check-format run-tests @@ -8,42 +8,26 @@ test: lint check-format run-tests .PHONY: lint # Perform lint checks against code lint: @echo "⚠️ 'lint' unimplemented" - # GO Projects - # @go vet && golint -set_exit_status ./... .PHONY: check-format # Checks code formatting and returns a non-zero exit code if formatting errors found check-format: @echo "⚠️ 'check-format' unimplemented" - # GO Projects - # @gofmt -e -l . .PHONY: format # Performs automatic format fixes on all code format: @echo "⚠️ 'format' unimplemented" - # GO Projects - # @gofmt -s -w . .PHONY: run-tests # Runs all tests run-tests: @echo "⚠️ 'run-tests' unimplemented" - # GO Projects - # @go test - # Node Projects - # @npm test .PHONY: fetch-deps # Fetch all project dependencies fetch-deps: @echo "⚠️ 'fetch-deps' unimplemented" - # GO Projects - # @go mod tidy - # Node Projects - # @npm install .PHONY: build # Build the project build: lint check-format fetch-deps @echo "⚠️ 'build' unimplemented" - # GO Projects - # @go build -o PROJECT_NAME main.go .PHONY: docker-build # Build the docker image docker-build: @@ -56,10 +40,6 @@ docker-publish: .PHONY: run # Run the application run: @echo "⚠️ 'run' unimplemented" - # GO Projects - # @go run main.go - # Node Projects - # @npm start .PHONY: ci # Perform CI specific tasks to perform on a pull request ci: diff --git a/giteaPR.sh b/giteaPR.sh new file mode 100644 index 0000000..456f553 --- /dev/null +++ b/giteaPR.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +REPO=$1 +SHA=$2 +STATE=$3 + +CONTEXT=${CONTEXT:-Tekton} +DESCRIPTION=${DESCRIPTION:-PR Pipeline} + +echo "Repo: ${REPO}" +echo "SHA: ${SHA}" +echo "State: ${STATE}" + +curl -X "POST" \ + "https://${GITEA_HOST}/api/v1/repos/${REPO}/statuses/${SHA}?access_token=${ACCESS_TOKEN}" \ + -H 'Content-Type: application/json; charset=utf-8' \ + -d $'{ + "state": "'$STATE'", + "context": "'$CONTEXT'", + "description": "'$DESCRIPTION'" + }'