From 6cdf7adebe4f31f09b84111beb45981475a44be9 Mon Sep 17 00:00:00 2001 From: Kris Crawford Date: Wed, 3 Apr 2024 17:09:35 -0400 Subject: [PATCH] Adding actions --- .gitea/workflows/build.yaml | 70 +++++++++++++++++++++++++++++++++++++ deployment.yaml | 4 +-- 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/build.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..d45d297 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,70 @@ +name: go-builder +run-name: go-builder +on: + push: + branches: + - release/* + +jobs: + build: + runs-on: gobuilder + container: + image: gobuilder:0.0.5 + steps: + - name: Clone + run: | + mkdir -p ~/.ssh + echo "${{ secrets.PI_GIT_KEY }}" | tr -d '\r' > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + ssh-keyscan git.kcrawford.net >> ~/.ssh/known_hosts + git clone --branch ${GITHUB_REF_NAME} git@git.kcrawford.net:${{env.GITHUB_REPOSITORY}}.git . + + - name: Inspect + run: | + env + #while true; do sleep 180; done + + - name: Create Release + id: release_num + run: | + TAG_NAME=$(basename ${GITHUB_REF_NAME}) + MESSAGE=$(echo ${{ github.event.head_commit.message }}) + + curl -sH "Content-Type: application/json" \ + -H "Authorization: token ${{secrets.REPO_API_RW_TOKEN}}" \ + -X POST ${{env.GITHUB_API_URL}}/repos/${{env.GITHUB_REPOSITORY}}/releases \ + -d '{"body": "Complied Binary Files", "draft": false, "name": "'"${MESSAGE}"'", "prerelease": false, "tag_name": "'"${TAG_NAME}"'" }' \ + --output site.output --write-out %{http_code} > http.response.code 2> error.messages + + if grep -q 201 http.response.code; then + id=$(jq '.id' < site.output) + echo "release_num=${id}" >> $GITHUB_OUTPUT + else + jq < site.output + exit 1 + fi + + - name: Build and upload + id: upload + needs: release_num + env: + ID: ${{steps.release_num.outputs.release_num}} + run: | + repo=$(basename ${{env.GITHUB_REPOSITORY}}) + go mod download + for os in linux darwin + do + for arch in arm64 amd64 + do + # Build + filename=${repo}_${os}_${arch} + echo "Building for" $filename + env CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go build -o ${filename} + + # Upload + curl -vH 'accept: application/json' \ + -H "Content-Type: multipart/form-data" \ + -H "Authorization: token ${{secrets.REPO_API_RW_TOKEN}}" \ + -X POST ${{env.GITHUB_API_URL}}/repos/${{env.GITHUB_REPOSITORY}}/releases/$ID/assets?name=$filename -F attachment=@"${filename}" + done + done diff --git a/deployment.yaml b/deployment.yaml index 9f72c9f..fb96faa 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -16,7 +16,7 @@ spec: spec: containers: - name: http-header - image: git.10bit.link/kcrawford/golang-http-header:0.0.4 + image: git.kcrawford.net/kcrawford/golang-http-header:0.0.4 ports: - containerPort: 8000 @@ -31,4 +31,4 @@ spec: ports: - protocol: TCP port: 80 - targetPort: 8000 \ No newline at end of file + targetPort: 8000