Add CI workflows

This commit is contained in:
James Mills 2024-08-25 15:21:02 +10:00
parent f69d56187b
commit 929a899656
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6
3 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,23 @@
---
name: 🛠️ Build
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Install Build Dependencies
run: make deps
- name: Build Binary
run: make build

View File

@ -0,0 +1,62 @@
---
name: 🚀 Publish
on:
push:
branches: [main]
pull_request:
env:
REGISTRY: r.mills.io
IMAGE: prologic/zs
TAG: latest
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Docker Buildx
uses: actions/setup-buildx@v2
- name: Login to Registry
uses: actions/docker-login@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- name: Build Info
id: build-info
run: |
{
echo "VERSION=$(git describe --abbrev=0)"
echo "COMMIT=$(git rev-parse --short HEAD)"
echo "BUILD=$(git show -s --pretty=format:%cI)"
} >> "$GITHUB_OUTPUT"
- name: Build Image
uses: actions/docker-build-push@v4
with:
context: .
load: true
tags: ${{ env.REGISTRY}}/${{ env.IMAGE }}:${{ env.TAG }}
build-args: |
VERSION=${{ steps.build-info.outputs.VERSION }}
COMMIT=${{ steps.build-info.outputs.COMMIT }}
BUILD=${{ steps.build-info.outputs.BUILD }}
- name: Test Image
run: |
docker run --rm ${{ env.REGISTRY}}/${{ env.IMAGE }}:${{ env.TAG }} zs --version
- name: Publish Image
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
uses: actions/docker-build-push@v4
with:
context: .
push: true
tags: ${{ env.REGISTRY}}/${{ env.IMAGE }}:${{ env.TAG }}
build-args: |
VERSION=${{ steps.build-info.outputs.VERSION }}
COMMIT=${{ steps.build-info.outputs.COMMIT }}
BUILD=${{ steps.build-info.outputs.BUILD }}

26
.gitea/workflows/test.yml Normal file
View File

@ -0,0 +1,26 @@
---
name: 🧪 Test
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
services:
tile38:
image: tile38/tile38:1.32.2
ports:
- "9851:9851/tcp"
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Run Tests
run: make test