Skip to content

v3.1.5

v3.1.5 #20

Workflow file for this run

name: Docker Build
on:
release:
types: [created]
jobs:
setup:
if: contains('["libsgh"]', github.actor)
name: build setup
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.setup.outputs.branch }}
target: ${{ steps.setup.outputs.target }}
image_name: ${{ steps.setup.outputs.image_name }}
version: ${{ steps.setup.outputs.version }}
image_base: ${{ steps.setup.outputs.image_base }}
steps:
- name: setup
id: setup
run: |
target='["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/s390x", "linux/386", "linux/arm/v7", "linux/arm/v6"]'
branch='["main"]'
image_base='iicm/pan-index'
ref=${{ github.ref }}
version=$(basename ${ref})
image_name='["'${image_base}':'${version}'", "'${image_base}':latest"]'
list=$(echo ${target} | jq -c)
echo "target=${list}" >> $GITHUB_OUTPUT
b=$(echo ${branch} | jq -c)
echo "branch=${b}" >> $GITHUB_OUTPUT
images=$(echo ${image_name} | jq -c)
echo "image_name=${images}" >> $GITHUB_OUTPUT
echo "version=${version}" >> $GITHUB_OUTPUT
echo "image_base=${image_base}" >> $GITHUB_OUTPUT
build:
if: contains('["libsgh"]', github.actor)
needs: setup
strategy:
matrix:
target: ${{ fromJson(needs.setup.outputs.target) }}
branch: ${{ fromJson(needs.setup.outputs.branch) }}
go-version: [1.20.1]
name: build
runs-on: ubuntu-latest
outputs:
artifact_name: ${{ steps.artifact.outputs.name }}
steps:
- name: Setup Artifact Name
id: artifact
run: |
tar=${{ matrix.target }}
a=${tar//'/'/'-'}
echo "name=${a}" >> $GITHUB_OUTPUT
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ steps.artifact.outputs.name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ steps.artifact.outputs.name }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: iicm
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
push: true
provenance: false
sbom: false
build-args: |
GO_VERSION=${{ matrix.go-version }}
VERSION=${{ github.ref }}
TYPE=nightly_build_docker
APP_NAME=PanIndex
tags: ${{ needs.setup.outputs.image_base }}:latest-${{ steps.artifact.outputs.name }},${{ needs.setup.outputs.image_base }}:${{ needs.setup.outputs.version }}-${{ steps.artifact.outputs.name }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.target }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
combine:
if: contains('["libsgh"]', github.actor)
runs-on: ubuntu-latest
needs:
- setup
- build
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: iicm
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Combine images
run: |
for image_name in ${{ join(fromJson(needs.setup.outputs.image_name), ' ') }}
do
args=""
remove_tags=""
for target in ${{ join(fromJson(needs.setup.outputs.target), ' ') }}
do
name=${target//'/'/'-'}
remove_tags="$remove_tags ${image_name}-$name"
args="$args --amend ${image_name}-$name"
done
docker manifest create ${image_name} ${args}
docker manifest push --purge ${image_name}
docker run --rm lumir/remove-dockerhub-tag --user iicm \
--password ${{ secrets.DOCKERHUB_PASSWORD }} ${remove_tags}
done
shell: bash