mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-06-20 01:47:43 +02:00
Updated building images workflow
This commit is contained in:
parent
17854452e3
commit
2ca0e27b65
33
.github/workflows/images_build.yml
vendored
33
.github/workflows/images_build.yml
vendored
@ -49,6 +49,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
actions: write
|
||||||
outputs:
|
outputs:
|
||||||
os: ${{ steps.os.outputs.list }}
|
os: ${{ steps.os.outputs.list }}
|
||||||
database: ${{ steps.database.outputs.list }}
|
database: ${{ steps.database.outputs.list }}
|
||||||
@ -150,6 +151,28 @@ jobs:
|
|||||||
echo "current_branch=$github_ref" >> $GITHUB_OUTPUT
|
echo "current_branch=$github_ref" >> $GITHUB_OUTPUT
|
||||||
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
|
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Cleanup cache
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
BRANCH: ${{ steps.branch_info.outputs.current_branch }}
|
||||||
|
GH_RUN_ID: ${{ github.run_id }}
|
||||||
|
run: |
|
||||||
|
gh extension install actions/gh-actions-cache
|
||||||
|
|
||||||
|
cache_keys=$(gh actions-cache list -R "${REPO}" -B "${BRANCH}" -L 100 --sort created-at --order desc | cut -f 1)
|
||||||
|
|
||||||
|
## Setting this to not fail the workflow while deleting cache keys
|
||||||
|
set +e
|
||||||
|
echo "Deleting caches..."
|
||||||
|
for cache_key in $cache_keys
|
||||||
|
do
|
||||||
|
if [[ "$cache_key" == *"${GH_RUN_ID}" ]] && [[ "$cache_key" != *"${GH_RUN_ID}-image" ]]; then
|
||||||
|
gh actions-cache delete $cache_key -R "${REPO}" -B "${BRANCH}" --confirm
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
build_base:
|
build_base:
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
name: Build base on ${{ matrix.os }}
|
name: Build base on ${{ matrix.os }}
|
||||||
@ -355,7 +378,7 @@ jobs:
|
|||||||
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-base-cache
|
path: /tmp/.buildx-base-cache
|
||||||
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.os }}-${{ github.run_id }}
|
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.os }}-${{ github.run_id }}-image
|
||||||
|
|
||||||
- name: Build and publish image
|
- name: Build and publish image
|
||||||
id: docker_build
|
id: docker_build
|
||||||
@ -376,7 +399,7 @@ jobs:
|
|||||||
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-base-cache
|
path: /tmp/.buildx-base-cache
|
||||||
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.os }}-${{ github.run_id }}
|
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.os }}-${{ github.run_id }}-image
|
||||||
|
|
||||||
- name: Sign the images with GitHub OIDC Token
|
- name: Sign the images with GitHub OIDC Token
|
||||||
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
@ -576,13 +599,13 @@ jobs:
|
|||||||
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-base-cache
|
path: /tmp/.buildx-base-cache
|
||||||
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.os }}-${{ github.run_id }}
|
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.os }}-${{ github.run_id }}-image
|
||||||
|
|
||||||
- name: Download metadata of ${{ matrix.build }}:${{ matrix.os }}
|
- name: Download metadata of ${{ matrix.build }}:${{ matrix.os }}
|
||||||
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-build-cache
|
path: /tmp/.buildx-build-cache
|
||||||
key: ${{ matrix.build }}-${{ matrix.os }}-${{ github.run_id }}
|
key: ${{ matrix.build }}-${{ matrix.os }}-${{ github.run_id }}-image
|
||||||
|
|
||||||
- name: Prepare cache data
|
- name: Prepare cache data
|
||||||
id: cache_data
|
id: cache_data
|
||||||
@ -641,7 +664,7 @@ jobs:
|
|||||||
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-build-cache
|
path: /tmp/.buildx-build-cache
|
||||||
key: ${{ matrix.build }}-${{ matrix.os }}-${{ github.run_id }}
|
key: ${{ matrix.build }}-${{ matrix.os }}-${{ github.run_id }}-image
|
||||||
|
|
||||||
- name: Sign the images with GitHub OIDC Token
|
- name: Sign the images with GitHub OIDC Token
|
||||||
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user