Skip to content

Commit

Permalink
new paralell action docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
H3rmt committed Oct 12, 2023
1 parent 687c56f commit 48b6511
Showing 1 changed file with 68 additions and 12 deletions.
80 changes: 68 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
name: Release

on:
release:
types: [prereleased, released]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Echo
run: echo "releasing:${{ env.RELEASE_VERSION }}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.REGISTRY_IMAGE }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
Expand All @@ -26,15 +36,61 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN }}
- name: Build and push
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/localfilesharing:latest
${{ secrets.DOCKERHUB_USERNAME }}/localfilesharing:${{ env.RELEASE_VERSION }}
ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/localfilesharing:latest
ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/localfilesharing:${{ env.RELEASE_VERSION }}
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ secrets.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.REGISTRY_IMAGE }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ secrets.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ secrets.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

0 comments on commit 48b6511

Please sign in to comment.