mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-05-04 10:33:47 +01:00
refactor: publish registry image
This commit is contained in:
parent
da3b8f3b04
commit
372f9b6714
1 changed files with 29 additions and 88 deletions
115
.github/workflows/registry.yaml
vendored
115
.github/workflows/registry.yaml
vendored
|
@ -33,109 +33,50 @@ jobs:
|
||||||
version: ${{ steps.read_toml.outputs.value }}
|
version: ${{ steps.read_toml.outputs.value }}
|
||||||
registry_image: "ghcr.io/${{ steps.repository_owner.outputs.lowercase }}/registry"
|
registry_image: "ghcr.io/${{ steps.repository_owner.outputs.lowercase }}/registry"
|
||||||
|
|
||||||
build:
|
publish-registry-image:
|
||||||
|
name: Build and publish Docker package
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
needs:
|
needs: [ prepare ]
|
||||||
- prepare
|
env:
|
||||||
strategy:
|
VERSION: ${{ needs.prepare.outputs.version }}
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
platform:
|
|
||||||
- linux /amd64
|
|
||||||
- linux/arm64
|
|
||||||
steps:
|
steps:
|
||||||
- name: Prepare
|
- name: Checkout repository
|
||||||
run: |
|
uses: actions/checkout@v3
|
||||||
platform=${{ matrix.platform }}
|
|
||||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Log in to the Container registry
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ needs.prepare.outputs.registry_image }}
|
|
||||||
|
|
||||||
- name: Login to GHCR
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: https://ghcr.io
|
registry: https://ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set Tags
|
||||||
|
id: set_tags
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
TAGS=$({
|
||||||
|
echo "${{ needs.prepare.outputs.registry_image }}:${{ github.sha }}"
|
||||||
|
echo "${{ needs.prepare.outputs.registry_image }}:${{ needs.prepare.outputs.version }}"
|
||||||
|
if [[ "${{ needs.prepare.outputs.version }}" != *"-"* ]]; then
|
||||||
|
echo "${{ needs.prepare.outputs.registry_image }}:latest"
|
||||||
|
fi
|
||||||
|
})
|
||||||
|
echo "tags<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "$TAGS" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build and push by digest
|
- name: Build and push Docker image
|
||||||
id: build
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
platforms: ${{ matrix.platform }}
|
context: .
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
platforms: linux/amd64,linux/arm64
|
||||||
tags: ${{ needs.prepare.outputs.registry_image }}
|
push: true
|
||||||
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
|
tags: ${{ steps.set_tags.outputs.tags }}
|
||||||
|
|
||||||
- name: Export digest
|
|
||||||
run: |
|
|
||||||
mkdir -p ${{ runner.temp }}/digests
|
|
||||||
digest="${{ steps.build.outputs.digest }}"
|
|
||||||
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
|
||||||
|
|
||||||
- name: Upload digest
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: digests-${{ env.PLATFORM_PAIR }}
|
|
||||||
path: ${{ runner.temp }}/digests/*
|
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
merge:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
needs:
|
|
||||||
- prepare
|
|
||||||
- build
|
|
||||||
steps:
|
|
||||||
- name: Download digests
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
path: ${{ runner.temp }}/digests
|
|
||||||
pattern: digests-*
|
|
||||||
merge-multiple: true
|
|
||||||
|
|
||||||
- name: Login to GHCR
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: https://ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Set Tags
|
|
||||||
id: set_tags
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
TAGS=$( {
|
|
||||||
echo "-t ${{ needs.prepare.outputs.registry_image }}:${{ github.sha }}";
|
|
||||||
echo "-t ${{ needs.prepare.outputs.registry_image }}:${{ needs.prepare.outputs.version }}";
|
|
||||||
if [[ "${{ needs.prepare.outputs.version }}" != *"-"* ]]; then
|
|
||||||
echo "-t ${{ needs.prepare.outputs.registry_image }}:latest";
|
|
||||||
fi;
|
|
||||||
} | paste -sd " " -)
|
|
||||||
echo "tags=$TAGS" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Create manifest list and push
|
|
||||||
working-directory: ${{ runner.temp }}/digests
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools create ${{ steps.set_tags.outputs.tags }} $(printf '${{ needs.prepare.outputs.registry_image }}@sha256:%s ' *)
|
|
||||||
|
|
||||||
- name: Inspect image
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools inspect ${{ needs.prepare.outputs.registry_image }}:${{ needs.prepare.outputs.version }}
|
|
Loading…
Add table
Reference in a new issue