mirror of
https://github.com/0x2E/fusion.git
synced 2026-06-18 18:34:31 +00:00
102 lines
3.2 KiB
YAML
102 lines
3.2 KiB
YAML
name: docker
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- backend/**
|
|
- frontend/**
|
|
- Dockerfile
|
|
- .dockerignore
|
|
- scripts.sh
|
|
- .github/workflows/docker.yml
|
|
- .github/actions/setup-toolchains/action.yml
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0 # for vite extracting git tag/hash
|
|
- name: Normalize repository name
|
|
run: echo "REPOSITORY=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
rook1e404/fusion
|
|
ghcr.io/${{ env.REPOSITORY }}
|
|
tags: |
|
|
# on release: tag with version (e.g., v1.2.3)
|
|
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }}
|
|
# on push to main: tag with main
|
|
type=raw,value=main,enable=${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
- name: Set up toolchains
|
|
if: github.event_name == 'push'
|
|
uses: ./.github/actions/setup-toolchains
|
|
with:
|
|
setup-node: "true"
|
|
- name: Build binaries from source
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
mkdir -p ./build
|
|
rm -f ./build/fusion-linux-amd64 ./build/fusion-linux-arm64
|
|
./scripts.sh build-frontend
|
|
./scripts.sh build-backend linux amd64 ./build/fusion-linux-amd64
|
|
./scripts.sh build-backend linux arm64 ./build/fusion-linux-arm64
|
|
- name: Download binaries from release assets
|
|
if: github.event_name == 'release'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
mkdir -p ./build
|
|
gh release download "${{ github.event.release.tag_name }}" \
|
|
--pattern "fusion-linux-amd64" \
|
|
--pattern "fusion-linux-arm64" \
|
|
--dir ./build
|
|
- name: Verify prepared binaries
|
|
run: |
|
|
test -f ./build/fusion-linux-amd64
|
|
test -f ./build/fusion-linux-arm64
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: amd64,arm64
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ github.token }}
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|