mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-17 15:27:28 +00:00
Workflow optimized using matrix
Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com>
This commit is contained in:
parent
2a14cea7d0
commit
95c69bda5c
120
.github/workflows/docker.yml
vendored
120
.github/workflows/docker.yml
vendored
@ -16,15 +16,34 @@ env:
|
||||
|
||||
|
||||
jobs:
|
||||
# Linux amd64
|
||||
linux-amd64:
|
||||
name: Linux amd64
|
||||
runs-on: ubuntu-latest
|
||||
# Build platform specific image
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
target:
|
||||
- os: linux
|
||||
arch: amd64
|
||||
- os: linux
|
||||
arch: arm64
|
||||
include:
|
||||
- target:
|
||||
os: linux
|
||||
arch: amd64
|
||||
builder: ubuntu-22.04
|
||||
- target:
|
||||
os: linux
|
||||
arch: arm64
|
||||
builder: buildjet-4vcpu-ubuntu-2204-arm
|
||||
|
||||
name: Build ${{ matrix.target.os }}/${{ matrix.target.arch }}
|
||||
runs-on: ${{ matrix.builder }}
|
||||
outputs:
|
||||
tags: ${{ steps.tags.outputs.tags }}
|
||||
tags-linux-amd64: ${{ steps.tags.outputs.tags-linux-amd64 }}
|
||||
tags-linux-arm64: ${{ steps.tags.outputs.tags-linux-arm64 }}
|
||||
env:
|
||||
PLATFORM: linux/amd64
|
||||
SUFFIX: linux-amd64
|
||||
PLATFORM: ${{ format('{0}/{1}', 'linux', matrix.target.arch) }}
|
||||
SUFFIX: ${{ format('{0}-{1}', 'linux', matrix.target.arch) }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -43,7 +62,12 @@ jobs:
|
||||
- name: Docker - Set tags output
|
||||
if: github.event_name != 'pull_request'
|
||||
id: tags
|
||||
run: echo "tags=${{ steps.meta.outputs.tags }}" >> "$GITHUB_OUTPUT"
|
||||
run: |
|
||||
if [[ '${{ matrix.target.os }}' == 'linux' && '${{ matrix.target.arch }}' == 'amd64' ]]; then
|
||||
echo "tags-linux-amd64=${{ steps.meta.outputs.tags }}" >> "$GITHUB_OUTPUT"
|
||||
elif [[ '${{ matrix.target.os }}' == 'linux' && '${{ matrix.target.arch }}' == 'arm64' ]]; then
|
||||
echo "tags-linux-arm64=${{ steps.meta.outputs.tags }}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Docker - Login to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
@ -89,85 +113,12 @@ jobs:
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
# Linux arm64
|
||||
linux-arm64:
|
||||
name: Linux arm64
|
||||
runs-on: buildjet-4vcpu-ubuntu-2204-arm
|
||||
outputs:
|
||||
tags: ${{ steps.tags.outputs.tags }}
|
||||
env:
|
||||
PLATFORM: linux/arm64
|
||||
SUFFIX: linux-arm64
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Docker - Meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: ${{ env.DOCKER_REPO }}
|
||||
flavor: |
|
||||
latest=false
|
||||
tags: |
|
||||
type=semver,pattern={{version}},suffix=-${{ env.SUFFIX }}
|
||||
type=sha,suffix=-${{ env.SUFFIX }},enable=${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
|
||||
- name: Docker - Set tags output
|
||||
if: github.event_name != 'pull_request'
|
||||
id: tags
|
||||
run: echo "tags=${{ steps.meta.outputs.tags }}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Docker - Login to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Docker - Build and export to Docker
|
||||
id: build
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ${{ env.DOCKER_FILE }}
|
||||
platforms: ${{ env.PLATFORM }}
|
||||
load: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
- name: Docker - Minify image
|
||||
uses: kitabisa/docker-slim-action@v1
|
||||
id: slim
|
||||
env:
|
||||
DSLIM_HTTP_PROBE: false
|
||||
with:
|
||||
target: ${{ steps.meta.outputs.tags }}
|
||||
overwrite: true
|
||||
|
||||
- name: Docker - Show slim report
|
||||
run: echo "${REPORT}" | jq -r
|
||||
env:
|
||||
REPORT: ${{ steps.slim.outputs.report }}
|
||||
|
||||
- name: Docker - Push to Docker registry
|
||||
if: github.event_name != 'pull_request'
|
||||
id: push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ${{ env.DOCKER_FILE }}
|
||||
platforms: ${{ env.PLATFORM }}
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
# Push single image
|
||||
# Publish single image
|
||||
publish:
|
||||
name: Push single image
|
||||
if: github.event_name != 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
needs: [linux-amd64, linux-arm64]
|
||||
needs: build
|
||||
steps:
|
||||
- name: Docker - Meta
|
||||
id: meta
|
||||
@ -183,7 +134,6 @@ jobs:
|
||||
# Transform multi-line tags in to the comma-seperated
|
||||
TAGS=$(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ',' | awk '{gsub(/,$/,"");}1')
|
||||
echo "TAGS=${TAGS}" >>$GITHUB_ENV
|
||||
echo "${TAGS}"
|
||||
|
||||
- name: Docker - Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
@ -195,5 +145,5 @@ jobs:
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
inputs: ${{ env.TAGS }}
|
||||
images: ${{ needs.linux-amd64.outputs.tags }},${{ needs.linux-arm64.outputs.tags }}
|
||||
images: ${{ needs.build.outputs.tags-linux-amd64 }},${{ needs.build.outputs.tags-linux-arm64 }}
|
||||
push: true
|
||||
|
Loading…
x
Reference in New Issue
Block a user