Skip to content

Commit 7c0e1e5

Browse files
Merge pull request #142 from Impre-visible/test/workflow
test: improve workflow cache
2 parents 4ff4b0a + c4ebafd commit 7c0e1e5

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

.github/workflows/docker-publish.yml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,39 @@ jobs:
2727
- name: Lowercase repo name
2828
run: echo "REPO_NAME_LOWER=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
2929

30-
- name: Set image tags
30+
- name: Set image tags and cache reference
3131
run: |
3232
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
33+
# Pour les releases (tags)
3334
TAG=${GITHUB_REF#refs/tags/}
3435
echo "IMAGE_TAGS=ghcr.io/${REPO_NAME_LOWER}:${TAG},ghcr.io/${REPO_NAME_LOWER}:latest" >> $GITHUB_ENV
36+
echo "CACHE_REF=release" >> $GITHUB_ENV
37+
echo "Build type: Release (tag: ${TAG})"
38+
elif [[ "${GITHUB_REF}" == refs/heads/test/workflow ]]; then
39+
# Pour la branche test/workflow spécifiquement
40+
echo "IMAGE_TAGS=ghcr.io/${REPO_NAME_LOWER}:test-workflow" >> $GITHUB_ENV
41+
echo "CACHE_REF=test-workflow" >> $GITHUB_ENV
42+
echo "Build type: Test workflow branch"
3543
elif [[ "${GITHUB_REF}" == refs/heads/* ]]; then
44+
# Pour les autres branches (au cas où)
3645
BRANCH_NAME=${GITHUB_REF#refs/heads/}
3746
SAFE_BRANCH_NAME=${BRANCH_NAME//\//-}
3847
echo "IMAGE_TAGS=ghcr.io/${REPO_NAME_LOWER}:${SAFE_BRANCH_NAME}" >> $GITHUB_ENV
48+
echo "CACHE_REF=branch-${SAFE_BRANCH_NAME}" >> $GITHUB_ENV
49+
echo "Build type: Other branch (${BRANCH_NAME})"
3950
else
51+
# Fallback
4052
echo "IMAGE_TAGS=ghcr.io/${REPO_NAME_LOWER}:latest" >> $GITHUB_ENV
53+
echo "CACHE_REF=default" >> $GITHUB_ENV
54+
echo "Build type: Default"
4155
fi
4256
43-
- name: Set CACHE_REF based on Git ref
57+
- name: Display cache configuration
4458
run: |
45-
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
46-
echo "CACHE_REF=release" >> $GITHUB_ENV
47-
else
48-
# Extrait le nom de la branche
49-
echo "CACHE_REF=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
50-
fi
59+
echo "🚀 Cache configuration:"
60+
echo " Cache reference: ${{ env.CACHE_REF }}"
61+
echo " Image tags: ${{ env.IMAGE_TAGS }}"
62+
echo " Git ref: ${GITHUB_REF}"
5163
5264
- name: Extract metadata
5365
id: meta
@@ -67,10 +79,10 @@ jobs:
6779
[worker.oci]
6880
max-parallelism = 8
6981
70-
71-
- name: Check Docker cache
82+
- name: Check existing Docker cache
7283
run: |
73-
docker buildx du
84+
echo "🔍 Checking existing cache for scope: ${{ env.CACHE_REF }}"
85+
docker buildx du || true
7486
7587
- name: Build and push Docker image
7688
uses: docker/build-push-action@v5
@@ -82,3 +94,9 @@ jobs:
8294
platforms: linux/amd64,linux/arm64
8395
cache-from: type=gha,mode=max,scope=${{ env.CACHE_REF }}
8496
cache-to: type=gha,mode=max,scope=${{ env.CACHE_REF }}
97+
98+
- name: Display build summary
99+
run: |
100+
echo "✅ Build completed successfully!"
101+
echo " Images pushed: ${{ env.IMAGE_TAGS }}"
102+
echo " Cache scope used: ${{ env.CACHE_REF }}"

0 commit comments

Comments
 (0)