Adding actions

This commit is contained in:
Kris Crawford 2024-04-03 17:09:35 -04:00
parent e1375565e0
commit 6cdf7adebe
2 changed files with 72 additions and 2 deletions

View File

@ -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

View File

@ -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