From 929a899656b6fc946d3790009a6ef058de1e8463 Mon Sep 17 00:00:00 2001 From: James Mills Date: Sun, 25 Aug 2024 15:21:02 +1000 Subject: [PATCH] Add CI workflows --- .gitea/workflows/build.yml | 23 +++++++++++++ .gitea/workflows/publish.yml | 62 ++++++++++++++++++++++++++++++++++++ .gitea/workflows/test.yml | 26 +++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 .gitea/workflows/build.yml create mode 100644 .gitea/workflows/publish.yml create mode 100644 .gitea/workflows/test.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..b681cd8 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -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 diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..921b737 --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -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 }} diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml new file mode 100644 index 0000000..c22d509 --- /dev/null +++ b/.gitea/workflows/test.yml @@ -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