diff --git a/.github/workflows/coolify-branch-arm64.yml b/.github/workflows/coolify-branch-arm64.yml index d94a84097d..5d4bc872e6 100644 --- a/.github/workflows/coolify-branch-arm64.yml +++ b/.github/workflows/coolify-branch-arm64.yml @@ -1,4 +1,4 @@ -name: Build Coolify ARM64 Branch Image +name: Build Coolify Branch (ARM64) on: workflow_dispatch: @@ -7,42 +7,43 @@ permissions: contents: read packages: write +env: + GITHUB_REGISTRY: ghcr.io + IMAGE_NAME: coollabsio/coolify + jobs: - prepare: - runs-on: ubuntu-24.04 - outputs: - image_tag: ${{ steps.image.outputs.image_tag }} - version: ${{ steps.image.outputs.version }} - steps: - - name: Resolve image tag - id: image - env: - BRANCH_NAME: ${{ github.ref_name }} - run: | - IMAGE_TAG=$(echo "${BRANCH_NAME}" | tr '[:upper:]/_' '[:lower:]--' | sed -E 's/[^a-z0-9.-]+/-/g; s/^[.-]+//; s/[.-]+$//') - if [ -z "${IMAGE_TAG}" ]; then - echo "Could not create an image tag from branch: ${BRANCH_NAME}" - exit 1 - fi - - SHORT_SHA="${GITHUB_SHA::7}" - echo "image_tag=${IMAGE_TAG}" >> "${GITHUB_OUTPUT}" - echo "version=${IMAGE_TAG}.${SHORT_SHA}" >> "${GITHUB_OUTPUT}" - - build: - needs: prepare + build-push: runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v5 with: + ref: ${{ github.ref }} persist-credentials: false - - uses: docker/setup-buildx-action@v3 + - name: Set image tag and version + id: version + env: + SELECTED_BRANCH: ${{ github.ref_name }} + run: | + BRANCH_TAG=$(printf '%s' "$SELECTED_BRANCH" \ + | tr '[:upper:]' '[:lower:]' \ + | sed -E 's/[^a-z0-9.-]+/-/g; s/^[.-]+//; s/[.-]+$//; s/-+/-/g' \ + | cut -c1-128 \ + | sed -E 's/[.-]+$//') - - name: Login to GitHub Container Registry + if [ -z "$BRANCH_TAG" ]; then + echo "The selected branch does not contain valid Docker tag characters." + exit 1 + fi + + SHORT_SHA=$(git rev-parse --short=7 HEAD) + echo "branch_tag=$BRANCH_TAG" >> "$GITHUB_OUTPUT" + echo "version=${BRANCH_TAG}-${SHORT_SHA}" >> "$GITHUB_OUTPUT" + + - name: Login to ${{ env.GITHUB_REGISTRY }} uses: docker/login-action@v3 with: - registry: ghcr.io + registry: ${{ env.GITHUB_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -54,5 +55,5 @@ jobs: platforms: linux/arm64 push: true build-args: | - COOLIFY_VERSION=${{ needs.prepare.outputs.version }} - tags: ghcr.io/coollabsio/coolify:${{ needs.prepare.outputs.image_tag }} + COOLIFY_VERSION=${{ steps.version.outputs.version }} + tags: ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.branch_tag }}