From 05b068f479a5e00a04843ac558b986ddefcd7049 Mon Sep 17 00:00:00 2001 From: tombo Date: Fri, 18 Oct 2024 17:28:40 +0200 Subject: [PATCH] add gha --- .github/workflows/build-image.yaml | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/build-image.yaml diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml new file mode 100644 index 0000000..53ef465 --- /dev/null +++ b/.github/workflows/build-image.yaml @@ -0,0 +1,67 @@ +name: docker-build-proxy + +env: + registry: ghcr.io + +on: + push: + tags: + - "*" +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Get image tags + id: tag + run: | + if [[ ${GITHUB_REF_TYPE} == tag ]]; then + tag=${GITHUB_REF##*/} + else + tag=${{ github.event.inputs.custom_tag }} + fi + echo "Tag: ${tag}" + echo "tag=$tag" >> $GITHUB_OUTPUT + - name: Checkout Server + uses: actions/checkout@v4 + with: + ref: ${{ steps.tag.outputs.tag }} + + - name: Create docker context + run: | + docker context create ctx + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + id: buildx + with: + endpoint: ctx + driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=10485760,env.BUILDKIT_STEP_LOG_MAX_SPEED=10485760 + + - name: Inspect builder + run: | + echo "Name: ${{ steps.buildx.outputs.name }}" + echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" + echo "Status: ${{ steps.buildx.outputs.status }}" + echo "Flags: ${{ steps.buildx.outputs.flags }}" + echo "Platforms: ${{ steps.buildx.outputs.platforms }}" + echo "Build tag ${{ steps.tag.outputs.tag }}" + - name: Login to GHRC + uses: docker/login-action@v2 + with: + registry: ${{ env.registry }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./ + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ env.registry }}/${{ github.repository }}:${{ steps.tag.outputs.tag }}, ${{ env.registry }}/${{ github.repository }}:latest + builder: ${{ steps.buildx.outputs.name }} + file: ./Dockerfile + provenance: false