From f8a43c9b1fd228f5a83a1a6af2af9ef141aec074 Mon Sep 17 00:00:00 2001 From: keven1024 Date: Sun, 1 Mar 2026 23:28:19 +0800 Subject: [PATCH] feat: add build and publish workflows for Docker images with automated tagging and deployment --- .gitea/workflows/build.yaml | 31 +++++++++++++++++++++ .gitea/workflows/lint.yaml | 37 ++++++++----------------- .gitea/workflows/publish.yaml | 52 +++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 26 deletions(-) create mode 100644 .gitea/workflows/build.yaml create mode 100644 .gitea/workflows/publish.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..d9ea440 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,31 @@ +name: Build + +on: + pull_request: + +jobs: + build-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: docker/setup-buildx-action@v3 + - name: Set build time + id: build-time + run: echo "time=$(date +%s)" >> $GITHUB_OUTPUT + - name: build-app + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: false + tags: 015-app:test + build-args: | + VERSION=${{ gitea.ref_name || github.ref_name }} + BUILD_TIME=${{ steps.build-time.outputs.time }} + - name: build-worker + uses: docker/build-push-action@v5 + with: + context: ./worker/ + file: ./worker/Dockerfile + push: false + tags: 015-worker:test \ No newline at end of file diff --git a/.gitea/workflows/lint.yaml b/.gitea/workflows/lint.yaml index 2363cd3..889c9a0 100644 --- a/.gitea/workflows/lint.yaml +++ b/.gitea/workflows/lint.yaml @@ -2,42 +2,31 @@ name: Lint on: push: - branches: - - 'dev' - pull_request: jobs: lint-front: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: Set up Node.js - uses: actions/setup-node@v6 + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 with: node-version: '24' - - - name: Install front dependencies + - uses: pnpm/action-setup@v4 + with: + cache: true + - name: Install dependencies run: | - corepack enable - corepack use pnpm@latest - pnpm i - + pnpm install --frozen-lockfile - name: Run frontend lint run: pnpm lint:front lint-backend: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: Set up Go - uses: actions/setup-go@v6 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: go-version-file: 'go.work' - - name: Run golangci-lint uses: golangci/golangci-lint-action@v9 with: @@ -47,14 +36,10 @@ jobs: lint-worker: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: Set up Go - uses: actions/setup-go@v6 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: go-version-file: 'go.work' - - name: Run golangci-lint uses: golangci/golangci-lint-action@v9 with: diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml new file mode 100644 index 0000000..48d2c21 --- /dev/null +++ b/.gitea/workflows/publish.yaml @@ -0,0 +1,52 @@ +name: Publish + +on: + push: + tags: + - '*' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + username: fudaoyuanicu + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: docker/metadata-action@v5 + with: + images: fudaoyuanicu/015-app + tags: | + type=ref,event=tag + type=raw,value=latest + - name: Set build time + id: build-time + run: | + echo "time=$(date +%s)" >> $GITHUB_OUTPUT + shell: bash + - name: build-app + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ gitea.ref_name || github.ref_name }} + BUILD_TIME=${{ steps.build-time.outputs.time }} + - name: build-worker + uses: docker/build-push-action@v5 + with: + context: ./worker/ + file: ./worker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Send deployment webhook + run: | + curl -X POST http://192.168.100.5:8364/v1/update \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer helloworld"