@@ -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 }}
0 commit comments