mirror of
https://github.com/Portabase/agent.git
synced 2026-09-11 14:00:14 +00:00
199 lines
5.4 KiB
YAML
199 lines
5.4 KiB
YAML
#name: Docker Publish
|
|
#
|
|
#on:
|
|
# workflow_call:
|
|
# inputs:
|
|
# image_name:
|
|
# required: false
|
|
# type: string
|
|
# default: 'portabase/agent'
|
|
# add_latest:
|
|
# required: false
|
|
# type: boolean
|
|
# default: false
|
|
# target:
|
|
# required: false
|
|
# type: string
|
|
# default: 'prod'
|
|
# dockerfile:
|
|
# required: false
|
|
# type: string
|
|
# default: './docker/Dockerfile'
|
|
# secrets:
|
|
# DOCKER_USERNAME:
|
|
# required: true
|
|
# DOCKER_PASSWORD:
|
|
# required: true
|
|
#
|
|
#jobs:
|
|
# build-and-push:
|
|
# runs-on: ubuntu-latest
|
|
# permissions:
|
|
# packages: write
|
|
# contents: read
|
|
# steps:
|
|
# - name: Check out the repo
|
|
# uses: actions/checkout@v4
|
|
# with:
|
|
# fetch-depth: 0
|
|
#
|
|
# - name: Set up QEMU (enables multi-arch emulation)
|
|
# uses: docker/setup-qemu-action@v3
|
|
#
|
|
# - name: Set up Docker Buildx
|
|
# uses: docker/setup-buildx-action@v3
|
|
#
|
|
# - name: Log in to Docker Hub
|
|
# uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
|
# with:
|
|
# username: ${{ secrets.DOCKER_USERNAME }}
|
|
# password: ${{ secrets.DOCKER_PASSWORD }}
|
|
#
|
|
# - name: Set tags
|
|
# id: set-tags
|
|
# run: |
|
|
# REF_NAME=${GITHUB_REF#refs/tags/}
|
|
# TAGS="${{ inputs.image_name }}:$REF_NAME"
|
|
# if [[ "${{ inputs.add_latest }}" == "true" ]]; then
|
|
# TAGS="$TAGS,${{ inputs.image_name }}:latest"
|
|
# fi
|
|
# echo "tags=$TAGS" >> $GITHUB_OUTPUT
|
|
#
|
|
# - name: Build and push Docker image
|
|
# uses: docker/build-push-action@v6
|
|
# with:
|
|
# context: .
|
|
# file: ${{ inputs.dockerfile }}
|
|
# platforms: linux/amd64,linux/arm64
|
|
# push: true
|
|
# tags: ${{ steps.set-tags.outputs.tags }}
|
|
# target: ${{ inputs.target }}
|
|
|
|
name: Docker Publish
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
image_name:
|
|
required: false
|
|
type: string
|
|
default: 'portabase/agent'
|
|
add_latest:
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
target:
|
|
required: false
|
|
type: string
|
|
default: 'prod'
|
|
dockerfile:
|
|
required: false
|
|
type: string
|
|
default: './docker/Dockerfile'
|
|
secrets:
|
|
DOCKER_USERNAME:
|
|
required: true
|
|
DOCKER_PASSWORD:
|
|
required: true
|
|
|
|
jobs:
|
|
build-amd64:
|
|
name: Build AMD64 Image
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
image: ${{ steps.set-tags.outputs.amd64_image }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Set image tag
|
|
id: set-tags
|
|
run: |
|
|
REF_NAME=${GITHUB_REF#refs/tags/}
|
|
AMD64_IMAGE="${{ inputs.image_name }}:$REF_NAME-amd64"
|
|
echo "amd64_image=$AMD64_IMAGE" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push AMD64
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ${{ inputs.dockerfile }}
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: ${{ steps.set-tags.outputs.amd64_image }}
|
|
target: ${{ inputs.target }}
|
|
|
|
- name: Set job output
|
|
run: |
|
|
echo "image=${{ steps.set-tags.outputs.amd64_image }}" >> $GITHUB_OUTPUT
|
|
|
|
build-arm64:
|
|
name: Build ARM64 Image
|
|
runs-on: ubuntu-24.04-arm
|
|
outputs:
|
|
image: ${{ steps.set-tags.outputs.arm64_image }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Set image tag
|
|
id: set-tags
|
|
run: |
|
|
REF_NAME=${GITHUB_REF#refs/tags/}
|
|
ARM64_IMAGE="${{ inputs.image_name }}:$REF_NAME-arm64"
|
|
echo "arm64_image=$ARM64_IMAGE" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push ARM64
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ${{ inputs.dockerfile }}
|
|
platforms: linux/arm64
|
|
push: true
|
|
tags: ${{ steps.set-tags.outputs.arm64_image }}
|
|
target: ${{ inputs.target }}
|
|
|
|
- name: Set job output
|
|
run: |
|
|
echo "image=${{ steps.set-tags.outputs.arm64_image }}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
create-manifest:
|
|
name: Create Multi-Arch Manifest
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-amd64
|
|
- build-arm64
|
|
steps:
|
|
- uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Create Docker manifest
|
|
run: |
|
|
REF_NAME=${GITHUB_REF#refs/tags/}
|
|
IMAGE="${{ inputs.image_name }}:$REF_NAME"
|
|
AMD64_IMAGE="${{ needs.build-amd64.outputs.image }}"
|
|
ARM64_IMAGE="${{ needs.build-arm64.outputs.image }}"
|
|
|
|
docker manifest create $IMAGE $AMD64_IMAGE $ARM64_IMAGE
|
|
docker manifest push $IMAGE
|
|
|
|
if [ "${{ inputs.add_latest }}" = "true" ]; then
|
|
docker manifest create ${{ inputs.image_name }}:latest $AMD64_IMAGE $ARM64_IMAGE
|
|
docker manifest push ${{ inputs.image_name }}:latest
|
|
fi
|