mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-20 18:23:40 +00:00
Add version checks and concurrency controls to helper and realtime image workflows, with tests covering registry validation.
162 lines
5.5 KiB
YAML
162 lines
5.5 KiB
YAML
name: Coolify Realtime
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
paths:
|
|
- .github/workflows/coolify-realtime.yml
|
|
- docker/coolify-realtime/**
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
env:
|
|
GITHUB_REGISTRY: ghcr.io
|
|
DOCKER_REGISTRY: docker.io
|
|
IMAGE_NAME: "coollabsio/coolify-realtime"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
check-version:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to ${{ env.GITHUB_REGISTRY }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.GITHUB_REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to ${{ env.DOCKER_REGISTRY }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.DOCKER_REGISTRY }}
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Ensure version is not published
|
|
run: |
|
|
BASE_VERSION=$(docker run --rm -v "$(pwd):/app" -w /app php:8.2-alpine3.16 php bootstrap/getRealtimeVersion.php)
|
|
VERSION="${BASE_VERSION}"
|
|
for registry in "${DOCKER_REGISTRY}" "${GITHUB_REGISTRY}"; do
|
|
IMAGE="${registry}/${IMAGE_NAME}:${VERSION}"
|
|
if output=$(docker buildx imagetools inspect "$IMAGE" 2>&1); then
|
|
echo "::error::Version $VERSION already exists in $registry"
|
|
exit 1
|
|
fi
|
|
if ! grep -Eqi 'manifest unknown|not found|no such manifest' <<< "$output"; then
|
|
echo "::error::Could not verify $IMAGE: $output"
|
|
exit 1
|
|
fi
|
|
done
|
|
echo "Version $VERSION is available in both registries"
|
|
|
|
build-push:
|
|
needs: check-version
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- arch: amd64
|
|
platform: linux/amd64
|
|
runner: ubuntu-24.04
|
|
- arch: aarch64
|
|
platform: linux/aarch64
|
|
runner: ubuntu-24.04-arm
|
|
runs-on: ${{ matrix.runner }}
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Login to ${{ env.GITHUB_REGISTRY }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.GITHUB_REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to ${{ env.DOCKER_REGISTRY }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.DOCKER_REGISTRY }}
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Get Version
|
|
id: version
|
|
run: |
|
|
echo "VERSION=$(docker run --rm -v "$(pwd):/app" -w /app php:8.2-alpine3.16 php bootstrap/getRealtimeVersion.php)"|xargs >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and Push Image (${{ matrix.arch }})
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: docker/coolify-realtime/Dockerfile
|
|
platforms: ${{ matrix.platform }}
|
|
push: true
|
|
tags: |
|
|
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-${{ matrix.arch }}
|
|
${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-${{ matrix.arch }}
|
|
labels: |
|
|
coolify.managed=true
|
|
|
|
merge-manifest:
|
|
runs-on: ubuntu-24.04
|
|
needs: build-push
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to ${{ env.GITHUB_REGISTRY }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.GITHUB_REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to ${{ env.DOCKER_REGISTRY }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.DOCKER_REGISTRY }}
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Get Version
|
|
id: version
|
|
run: |
|
|
echo "VERSION=$(docker run --rm -v "$(pwd):/app" -w /app php:8.2-alpine3.16 php bootstrap/getRealtimeVersion.php)"|xargs >> $GITHUB_OUTPUT
|
|
|
|
- name: Create & publish manifest on ${{ env.GITHUB_REGISTRY }}
|
|
run: |
|
|
docker buildx imagetools create \
|
|
${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-amd64 \
|
|
${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-aarch64 \
|
|
--tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} \
|
|
--tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
|
|
- name: Create & publish manifest on ${{ env.DOCKER_REGISTRY }}
|
|
run: |
|
|
docker buildx imagetools create \
|
|
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-amd64 \
|
|
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-aarch64 \
|
|
--tag ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} \
|
|
--tag ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
|
|
- uses: sarisia/actions-status-discord@v1
|
|
if: always()
|
|
with:
|
|
webhook: ${{ secrets.DISCORD_WEBHOOK_PROD_RELEASE_CHANNEL }}
|