Skip to content

Commit 69b15d4

Browse files
committed
ci: fix buildx auth order and PR cache handling
1 parent 29efbd1 commit 69b15d4

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

.github/workflows/build-devcontainer.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ jobs:
2323
- name: Checkout repository
2424
uses: actions/checkout@v6
2525

26-
- name: Compute image path
26+
- name: Compute image path and cache settings
2727
id: image
2828
run: |
2929
repo_lower=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')
3030
echo "name=ghcr.io/$repo_lower/devcontainer:latest" >> $GITHUB_OUTPUT
31-
echo "cache-ref=ghcr.io/$repo_lower/devcontainer:cache" >> $GITHUB_OUTPUT
31+
if [ "${{ github.event_name }}" = "pull_request" ]; then
32+
echo "cache-from=" >> $GITHUB_OUTPUT
33+
echo "cache-to=" >> $GITHUB_OUTPUT
34+
else
35+
echo "cache-from=type=registry,ref=ghcr.io/$repo_lower/devcontainer:cache" >> $GITHUB_OUTPUT
36+
echo "cache-to=type=registry,ref=ghcr.io/$repo_lower/devcontainer:cache,mode=max" >> $GITHUB_OUTPUT
37+
fi
3238
3339
- name: Log in to GitHub Container Registry
3440
if: github.event_name != 'pull_request'
@@ -38,12 +44,15 @@ jobs:
3844
username: ${{ github.actor }}
3945
password: ${{ secrets.GITHUB_TOKEN }}
4046

47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
4150
- name: Build and push devcontainer image
4251
uses: docker/build-push-action@v6
4352
with:
4453
context: .
4554
file: .devcontainer/Dockerfile
4655
push: ${{ github.event_name != 'pull_request' }}
4756
tags: ${{ steps.image.outputs.name }}
48-
cache-from: type=registry,ref=${{ steps.image.outputs.cache-ref }}
49-
cache-to: type=registry,ref=${{ steps.image.outputs.cache-ref }},mode=max
57+
cache-from: ${{ steps.image.outputs.cache-from }}
58+
cache-to: ${{ steps.image.outputs.cache-to }}

.github/workflows/checks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ jobs:
8585
username: ${{ github.actor }}
8686
password: ${{ secrets.GITHUB_TOKEN }}
8787

88+
- name: Set up Docker Buildx
89+
uses: docker/setup-buildx-action@v3
90+
8891
- name: Compute image path
8992
id: image
9093
run: |

0 commit comments

Comments
 (0)