feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
27
.github/workflows/ci.yml
поставляемый
Обычный файл
27
.github/workflows/ci.yml
поставляемый
Обычный файл
@@ -0,0 +1,27 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.26.x'
|
||||
cache: true
|
||||
- name: Check module files
|
||||
run: |
|
||||
go mod tidy
|
||||
git diff --exit-code -- go.mod go.sum
|
||||
- name: Test worker packages
|
||||
run: make test
|
||||
- name: Build binary
|
||||
run: make build
|
||||
79
.github/workflows/docker.yml
поставляемый
Обычный файл
79
.github/workflows/docker.yml
поставляемый
Обычный файл
@@ -0,0 +1,79 @@
|
||||
name: Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- v*
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
name: Build and publish worker image
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
HARBOR_REGISTRY: ${{ secrets.HARBOR_REGISTRY }}
|
||||
HARBOR_PROJECT: rsmon
|
||||
IMAGE_NAME: rsmon-worker
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Harbor
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.HARBOR_REGISTRY }}
|
||||
username: ${{ secrets.HARBOR_USER }}
|
||||
password: ${{ secrets.HARBOR_PASSWORD }}
|
||||
|
||||
- name: Compute image metadata
|
||||
id: vars
|
||||
env:
|
||||
REF_NAME: ${{ gitea.ref_name }}
|
||||
REF_TYPE: ${{ gitea.ref_type }}
|
||||
SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
IMAGE="${HARBOR_REGISTRY}/${HARBOR_PROJECT}/${IMAGE_NAME}"
|
||||
SHORT_SHA="$(printf '%s' "${SHA}" | cut -c1-12)"
|
||||
TAGS="${IMAGE}:sha-${SHORT_SHA}"
|
||||
if [ "${REF_TYPE}" = "branch" ] && [ "${REF_NAME}" = "master" ]; then
|
||||
TAGS="${TAGS},${IMAGE}:latest"
|
||||
fi
|
||||
if [ "${REF_TYPE}" = "tag" ]; then
|
||||
TAGS="${TAGS},${IMAGE}:${REF_NAME}"
|
||||
fi
|
||||
{
|
||||
echo "image=${IMAGE}"
|
||||
echo "tags=${TAGS}"
|
||||
echo "build_date=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
} >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Build and push image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
pull: true
|
||||
push: true
|
||||
tags: ${{ steps.vars.outputs.tags }}
|
||||
labels: |
|
||||
org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}
|
||||
org.opencontainers.image.revision=${{ gitea.sha }}
|
||||
org.opencontainers.image.version=${{ gitea.ref_name }}
|
||||
org.opencontainers.image.licenses=LicenseRef-RSMon-Worker-Source-Available-1.0
|
||||
build-args: |
|
||||
VERSION=${{ gitea.ref_name }}
|
||||
COMMIT=${{ gitea.sha }}
|
||||
BUILD_DATE=${{ steps.vars.outputs.build_date }}
|
||||
cache-from: type=registry,ref=${{ steps.vars.outputs.image }}:buildcache
|
||||
cache-to: type=registry,ref=${{ steps.vars.outputs.image }}:buildcache,mode=max
|
||||
sbom: true
|
||||
provenance: mode=max
|
||||
Ссылка в новой задаче
Block a user