mirror of
https://github.com/trycua/computer.git
synced 2025-12-31 02:19:58 -06:00
Add xfce gh action, simplify folder name
This commit is contained in:
144
.github/workflows/docker-publish-kasm.yml
vendored
144
.github/workflows/docker-publish-kasm.yml
vendored
@@ -9,141 +9,21 @@ on:
|
||||
paths:
|
||||
- "libs/kasm/**"
|
||||
- ".github/workflows/docker-publish-kasm.yml"
|
||||
- ".github/workflows/docker-reusable-publish.yml"
|
||||
pull_request:
|
||||
paths:
|
||||
- "libs/kasm/**"
|
||||
- ".github/workflows/docker-publish-kasm.yml"
|
||||
|
||||
|
||||
env:
|
||||
IMAGE_NAME: cua-ubuntu
|
||||
DOCKER_HUB_ORG: trycua
|
||||
- ".github/workflows/docker-reusable-publish.yml"
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
# todo unsupported base image
|
||||
# - windows/amd64
|
||||
# - darwin/amd64
|
||||
# - darwin/arm64
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Prepare platform tag
|
||||
id: platform
|
||||
run: |
|
||||
# Convert platform (e.g., linux/amd64) to a valid tag suffix (e.g., linux-amd64)
|
||||
PLATFORM_TAG=$(echo "${{ matrix.platform }}" | sed 's/\//-/g')
|
||||
echo "tag=${PLATFORM_TAG}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: trycua
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (PR)
|
||||
if: github.event_name == 'pull_request'
|
||||
id: meta-pr
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=${{ github.sha }}
|
||||
|
||||
- name: Extract metadata (main branch)
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
||||
id: meta-main
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Extract metadata (semantic version tag)
|
||||
if: startsWith(github.ref, 'refs/tags/docker-kasm-v')
|
||||
id: meta-semver
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}},prefix=docker-kasm-v
|
||||
type=semver,pattern={{major}}.{{minor}},prefix=docker-kasm-v
|
||||
type=semver,pattern={{major}},prefix=docker-kasm-v
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Build and push Docker image (PR)
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./libs/kasm
|
||||
file: ./libs/kasm/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta-pr.outputs.tags }}
|
||||
labels: ${{ steps.meta-pr.outputs.labels }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
cache-from: |
|
||||
type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }}
|
||||
type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:latest
|
||||
cache-to: type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }},mode=max
|
||||
|
||||
- name: Build and push Docker image (main branch)
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./libs/kasm
|
||||
file: ./libs/kasm/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta-main.outputs.tags }}
|
||||
labels: ${{ steps.meta-main.outputs.labels }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
cache-from: |
|
||||
type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }}
|
||||
type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:latest
|
||||
cache-to: type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }},mode=max
|
||||
|
||||
- name: Build and push Docker image (semantic version tag)
|
||||
if: startsWith(github.ref, 'refs/tags/docker-kasm-v')
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./libs/kasm
|
||||
file: ./libs/kasm/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta-semver.outputs.tags }}
|
||||
labels: ${{ steps.meta-semver.outputs.labels }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
cache-from: |
|
||||
type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }}
|
||||
type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:latest
|
||||
cache-to: type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }},mode=max
|
||||
|
||||
- name: Image digest
|
||||
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/docker-kasm-v')
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
||||
echo "Image pushed with digest ${{ steps.meta-pr.outputs.digest }}"
|
||||
elif [[ "${{ github.ref }}" == refs/tags/docker-kasm-v* ]]; then
|
||||
echo "Image pushed with digest ${{ steps.meta-semver.outputs.digest }}"
|
||||
else
|
||||
echo "Image pushed with digest ${{ steps.meta-main.outputs.digest }}"
|
||||
fi
|
||||
|
||||
- name: print image tags
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
||||
echo "Image tags: ${{ steps.meta-pr.outputs.tags }}"
|
||||
elif [[ "${{ github.ref }}" == refs/tags/docker-kasm-v* ]]; then
|
||||
echo "Image tags: ${{ steps.meta-semver.outputs.tags }}"
|
||||
else
|
||||
echo "Image tags: ${{ steps.meta-main.outputs.tags }}"
|
||||
fi
|
||||
publish:
|
||||
uses: ./.github/workflows/docker-reusable-publish.yml
|
||||
with:
|
||||
image_name: cua-ubuntu
|
||||
context_dir: libs/kasm
|
||||
dockerfile_path: Dockerfile
|
||||
tag_prefix: docker-kasm-v
|
||||
docker_hub_org: trycua
|
||||
secrets:
|
||||
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
29
.github/workflows/docker-publish-xfce.yml
vendored
Normal file
29
.github/workflows/docker-publish-xfce.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Build and Publish CUA XFCE Container
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "docker-xfce-v*.*.*"
|
||||
paths:
|
||||
- "libs/xfce/**"
|
||||
- ".github/workflows/docker-publish-xfce.yml"
|
||||
- ".github/workflows/docker-reusable-publish.yml"
|
||||
pull_request:
|
||||
paths:
|
||||
- "libs/xfce/**"
|
||||
- ".github/workflows/docker-publish-xfce.yml"
|
||||
- ".github/workflows/docker-reusable-publish.yml"
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
uses: ./.github/workflows/docker-reusable-publish.yml
|
||||
with:
|
||||
image_name: cua-xfce
|
||||
context_dir: libs/xfce
|
||||
dockerfile_path: Dockerfile
|
||||
tag_prefix: docker-xfce-v
|
||||
docker_hub_org: trycua
|
||||
secrets:
|
||||
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
155
.github/workflows/docker-reusable-publish.yml
vendored
Normal file
155
.github/workflows/docker-reusable-publish.yml
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
name: Reusable Docker Publish Workflow
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
image_name:
|
||||
description: "Name of the Docker image (e.g. cua-ubuntu, cua-xfce)"
|
||||
required: true
|
||||
type: string
|
||||
context_dir:
|
||||
description: "Directory containing the Dockerfile relative to workspace root (e.g. libs/kasm, libs/xfce)"
|
||||
required: true
|
||||
type: string
|
||||
dockerfile_path:
|
||||
description: "Path to Dockerfile relative to context_dir (e.g. Dockerfile)"
|
||||
required: false
|
||||
type: string
|
||||
default: "Dockerfile"
|
||||
tag_prefix:
|
||||
description: "Prefix for semantic version tags (e.g. docker-kasm-v, docker-xfce-v)"
|
||||
required: true
|
||||
type: string
|
||||
docker_hub_org:
|
||||
description: "Docker Hub organization name"
|
||||
required: false
|
||||
type: string
|
||||
default: "trycua"
|
||||
secrets:
|
||||
DOCKER_HUB_TOKEN:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Prepare platform tag
|
||||
id: platform
|
||||
run: |
|
||||
# Convert platform (e.g., linux/amd64) to a valid tag suffix (e.g., linux-amd64)
|
||||
PLATFORM_TAG=$(echo "${{ matrix.platform }}" | sed 's/\//-/g')
|
||||
echo "tag=${PLATFORM_TAG}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ inputs.docker_hub_org }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (PR)
|
||||
if: github.event_name == 'pull_request'
|
||||
id: meta-pr
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ inputs.docker_hub_org }}/${{ inputs.image_name }}
|
||||
tags: |
|
||||
type=raw,value=${{ github.sha }}
|
||||
|
||||
- name: Extract metadata (main branch)
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
||||
id: meta-main
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ inputs.docker_hub_org }}/${{ inputs.image_name }}
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Extract metadata (semantic version tag)
|
||||
if: startsWith(github.ref, format('refs/tags/{0}', inputs.tag_prefix))
|
||||
id: meta-semver
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ inputs.docker_hub_org }}/${{ inputs.image_name }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}},prefix=${{ inputs.tag_prefix }}
|
||||
type=semver,pattern={{major}}.{{minor}},prefix=${{ inputs.tag_prefix }}
|
||||
type=semver,pattern={{major}},prefix=${{ inputs.tag_prefix }}
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Build and push Docker image (PR)
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./${{ inputs.context_dir }}
|
||||
file: ./${{ inputs.context_dir }}/${{ inputs.dockerfile_path }}
|
||||
push: true
|
||||
tags: ${{ steps.meta-pr.outputs.tags }}
|
||||
labels: ${{ steps.meta-pr.outputs.labels }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
cache-from: |
|
||||
type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }}
|
||||
type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:latest
|
||||
cache-to: type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }},mode=max
|
||||
|
||||
- name: Build and push Docker image (main branch)
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./${{ inputs.context_dir }}
|
||||
file: ./${{ inputs.context_dir }}/${{ inputs.dockerfile_path }}
|
||||
push: true
|
||||
tags: ${{ steps.meta-main.outputs.tags }}
|
||||
labels: ${{ steps.meta-main.outputs.labels }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
cache-from: |
|
||||
type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }}
|
||||
type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:latest
|
||||
cache-to: type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }},mode=max
|
||||
|
||||
- name: Build and push Docker image (semantic version tag)
|
||||
if: startsWith(github.ref, format('refs/tags/{0}', inputs.tag_prefix))
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./${{ inputs.context_dir }}
|
||||
file: ./${{ inputs.context_dir }}/${{ inputs.dockerfile_path }}
|
||||
push: true
|
||||
tags: ${{ steps.meta-semver.outputs.tags }}
|
||||
labels: ${{ steps.meta-semver.outputs.labels }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
cache-from: |
|
||||
type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }}
|
||||
type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:latest
|
||||
cache-to: type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }},mode=max
|
||||
|
||||
- name: Image digest
|
||||
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || startsWith(github.ref, format('refs/tags/{0}', inputs.tag_prefix))
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
||||
echo "Image pushed with digest ${{ steps.meta-pr.outputs.digest }}"
|
||||
elif [[ "${{ github.ref }}" == refs/tags/${{ inputs.tag_prefix }}* ]]; then
|
||||
echo "Image pushed with digest ${{ steps.meta-semver.outputs.digest }}"
|
||||
else
|
||||
echo "Image pushed with digest ${{ steps.meta-main.outputs.digest }}"
|
||||
fi
|
||||
|
||||
- name: print image tags
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
||||
echo "Image tags: ${{ steps.meta-pr.outputs.tags }}"
|
||||
elif [[ "${{ github.ref }}" == refs/tags/${{ inputs.tag_prefix }}* ]]; then
|
||||
echo "Image tags: ${{ steps.meta-semver.outputs.tags }}"
|
||||
else
|
||||
echo "Image tags: ${{ steps.meta-main.outputs.tags }}"
|
||||
fi
|
||||
Reference in New Issue
Block a user