mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-11 13:49:03 +00:00
feb3d19987
- Updated .gitignore to include new binary paths and retain .gitkeep. - Modified Gitleaks configuration to ignore additional directories. - Adjusted CI workflows to prevent execution on version bump pushes and improved version bump handling in scripts. - Bumped BetterDesk Console Manager version to 3.3.136 in betterdesk.sh and related scripts.
289 lines
10 KiB
YAML
289 lines
10 KiB
YAML
# =============================================================================
|
|
# BetterDesk Docker Images - Build & Publish to GitHub Container Registry
|
|
# =============================================================================
|
|
# Images:
|
|
# ghcr.io/<owner>/betterdesk-server
|
|
# ghcr.io/<owner>/betterdesk-console
|
|
# ghcr.io/<owner>/betterdesk (all-in-one)
|
|
#
|
|
# Tags:
|
|
# - main push: latest, sha-<commit>
|
|
# - git tag v* / GitHub Release: semver (e.g. 3.0.0-alpha), exact ref (v3.0.0-alpha)
|
|
# - workflow_dispatch: optional custom tag via input
|
|
#
|
|
# Triggers: push main (path-filtered), push tag v*, release published, manual
|
|
# =============================================================================
|
|
|
|
name: Build & Publish Docker Images
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Image tag (e.g. v3.0.0-alpha or 3.0.0-alpha)'
|
|
required: false
|
|
default: 'latest'
|
|
type: string
|
|
|
|
push:
|
|
branches: [main, dev]
|
|
tags: ['v*']
|
|
paths:
|
|
- 'Dockerfile*'
|
|
- 'docker-compose*.yml'
|
|
- 'docker/**'
|
|
- 'betterdesk-server/**'
|
|
- 'web-nodejs/**'
|
|
- '.github/workflows/docker-publish.yml'
|
|
|
|
release:
|
|
types: [published]
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }}
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
# Shared tag rules for docker/metadata-action (keep in sync across build jobs)
|
|
DOCKER_METADATA_TAGS: |
|
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
|
|
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' && github.event_name == 'push' }}
|
|
type=ref,event=tag
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}},enable=${{ !contains(github.ref_name, '-') && (github.event_name != 'workflow_dispatch' || !contains(github.event.inputs.tag, '-')) }}
|
|
type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' && github.event.inputs.tag != 'latest' }}
|
|
type=sha,prefix=sha-,enable=${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') }}
|
|
|
|
jobs:
|
|
read-version:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
outputs:
|
|
version: ${{ steps.ver.outputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- id: ver
|
|
run: |
|
|
if [ -f VERSION ]; then
|
|
echo "version=$(tr -d '\n\r' < VERSION)" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "version=dev" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
build-server:
|
|
needs: read-version
|
|
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[version-bump]')
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
outputs:
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
json: ${{ steps.meta.outputs.json }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: docker/setup-buildx-action@v4
|
|
|
|
- uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v6
|
|
with:
|
|
images: ${{ env.IMAGE_PREFIX }}/betterdesk-server
|
|
tags: ${{ env.DOCKER_METADATA_TAGS }}
|
|
|
|
- name: Resolve image for SBOM/Trivy
|
|
id: scanref
|
|
run: |
|
|
tag_line="$(echo "${{ steps.meta.outputs.tags }}" | grep -m1 'betterdesk-server:' || true)"
|
|
if [ -z "$tag_line" ]; then
|
|
tag_line="${{ env.IMAGE_PREFIX }}/betterdesk-server:latest"
|
|
fi
|
|
echo "image=$tag_line" >> "$GITHUB_OUTPUT"
|
|
|
|
- uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.server
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
BETTERDESK_COMMIT_SHA=${{ github.sha }}
|
|
BETTERDESK_IMAGE_VERSION=${{ needs.read-version.outputs.version }}
|
|
BETTERDESK_PRODUCT_VERSION=${{ needs.read-version.outputs.version }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
- name: Generate SBOM
|
|
continue-on-error: true
|
|
uses: anchore/sbom-action@v0
|
|
env:
|
|
SYFT_REGISTRY_AUTH_USERNAME: ${{ github.actor }}
|
|
SYFT_REGISTRY_AUTH_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
image: ${{ steps.scanref.outputs.image }}
|
|
format: spdx-json
|
|
output-file: sbom-server.spdx.json
|
|
|
|
- name: Trivy vulnerability scan
|
|
continue-on-error: true
|
|
uses: aquasecurity/trivy-action@master
|
|
env:
|
|
TRIVY_USERNAME: ${{ github.actor }}
|
|
TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
image-ref: ${{ steps.scanref.outputs.image }}
|
|
format: table
|
|
exit-code: 0
|
|
severity: CRITICAL,HIGH
|
|
|
|
build-console:
|
|
needs: read-version
|
|
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[version-bump]')
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
outputs:
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: docker/setup-buildx-action@v4
|
|
|
|
- uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v6
|
|
with:
|
|
images: ${{ env.IMAGE_PREFIX }}/betterdesk-console
|
|
tags: ${{ env.DOCKER_METADATA_TAGS }}
|
|
|
|
- uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.console
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
BETTERDESK_COMMIT_SHA=${{ github.sha }}
|
|
BETTERDESK_IMAGE_VERSION=${{ needs.read-version.outputs.version }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
build-allinone:
|
|
needs: read-version
|
|
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[version-bump]')
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
outputs:
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: docker/setup-buildx-action@v4
|
|
|
|
- uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v6
|
|
with:
|
|
images: ${{ env.IMAGE_PREFIX }}/betterdesk
|
|
tags: ${{ env.DOCKER_METADATA_TAGS }}
|
|
|
|
- uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
BETTERDESK_COMMIT_SHA=${{ github.sha }}
|
|
BETTERDESK_IMAGE_VERSION=${{ needs.read-version.outputs.version }}
|
|
BETTERDESK_PRODUCT_VERSION=${{ needs.read-version.outputs.version }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
update-description:
|
|
needs: [build-server, build-console, build-allinone]
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name != 'pull_request' && (github.event_name != 'push' || !contains(github.event.head_commit.message, '[version-bump]'))
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Summary
|
|
env:
|
|
SERVER_TAGS: ${{ needs.build-server.outputs.tags }}
|
|
CONSOLE_TAGS: ${{ needs.build-console.outputs.tags }}
|
|
ALLINONE_TAGS: ${{ needs.build-allinone.outputs.tags }}
|
|
run: |
|
|
extract_tags() {
|
|
echo "$1" | sed -n 's/.*:\([^ ]*\)$/\1/p' | sort -u | paste -sd ', ' -
|
|
}
|
|
server_tags="$(extract_tags "$SERVER_TAGS")"
|
|
console_tags="$(extract_tags "$CONSOLE_TAGS")"
|
|
allinone_tags="$(extract_tags "$ALLINONE_TAGS")"
|
|
|
|
{
|
|
echo "## Docker images published"
|
|
echo ""
|
|
echo "| Image | Tags |"
|
|
echo "|-------|------|"
|
|
echo "| \`ghcr.io/${{ github.repository_owner }}/betterdesk-server\` | ${server_tags:-n/a} |"
|
|
echo "| \`ghcr.io/${{ github.repository_owner }}/betterdesk-console\` | ${console_tags:-n/a} |"
|
|
echo "| \`ghcr.io/${{ github.repository_owner }}/betterdesk\` | ${allinone_tags:-n/a} |"
|
|
echo ""
|
|
echo "### Pin a version (production — official all-in-one)"
|
|
echo "\`\`\`bash"
|
|
echo "export BETTERDESK_IMAGE_TAG=3.0.0"
|
|
echo "curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/docker-compose.quick.single.yml -o docker-compose.yml"
|
|
echo "docker compose pull"
|
|
echo "docker compose up -d"
|
|
echo "\`\`\`"
|
|
echo ""
|
|
echo "### Quick start (rolling latest)"
|
|
echo "\`\`\`bash"
|
|
echo "curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/docker-compose.quick.single.yml -o docker-compose.yml"
|
|
echo "BETTERDESK_IMAGE_TAG=latest docker compose up -d"
|
|
echo "\`\`\`"
|
|
echo ""
|
|
echo "### Legacy split layout (two images)"
|
|
echo "\`\`\`bash"
|
|
echo "curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/docker-compose.quick.yml -o docker-compose.yml"
|
|
echo "docker compose pull && docker compose up -d"
|
|
echo "\`\`\`"
|
|
echo ""
|
|
echo "### Package visibility"
|
|
echo "New GHCR packages default to **private**. Set each package to **Public** for unauthenticated pulls."
|
|
} >> "$GITHUB_STEP_SUMMARY"
|