ngbs 4 months ago
parent
commit
0b607e60ea
1 changed files with 9 additions and 29 deletions
  1. 9 29
      .github/workflows/build-caddy.yml

+ 9 - 29
.github/workflows/build-caddy.yml

@@ -1,13 +1,10 @@
 name: Build Caddy
 
 on:
-  # schedule:
-  #   - cron: "0 20 15,30 * *"
-  repository_dispatch:
-    types: [release]
-    repositories:
-      - caddyserver/caddy
   workflow_dispatch:
+  release:
+    types: [published]
+    repositories: [caddyserver/caddy]
 
 jobs:
   build-caddy:
@@ -23,15 +20,9 @@ jobs:
 
       - name: Set up Docker Buildx
         uses: docker/setup-buildx-action@v3
-        id: buildx
-
-      - name: Cache Docker layers
-        uses: actions/cache@v4
         with:
-          path: /tmp/.buildx-cache
-          key: ${{ runner.os }}-buildx-${{ github.sha }}
-          restore-keys: |
-            ${{ runner.os }}-buildx-
+          driver-opts: |
+            network=host
 
       - name: Login to Docker Hub
         uses: docker/login-action@v3
@@ -39,16 +30,15 @@ jobs:
           username: ${{ secrets.DOCKER_HUB_USERNAME }}
           password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
 
-      - name: Login to GitHub Container Registry
+      - name: Login to GHCR
         uses: docker/login-action@v3
         with:
           registry: ghcr.io
           username: ${{ github.actor }}
           password: ${{ secrets.GITHUB_TOKEN }}
 
-      - name: Build Caddy and push
+      - name: Build and push
         uses: docker/build-push-action@v5
-        id: docker_build_caddy
         with:
           context: ./caddy/v2
           file: ./caddy/v2/Dockerfile
@@ -58,15 +48,5 @@ jobs:
             ${{ secrets.DOCKER_HUB_USERNAME }}/caddy:${{ env.CADDY_VERSION }}
             ghcr.io/${{ github.repository }}/caddy:latest
             ghcr.io/${{ github.repository }}/caddy:${{ env.CADDY_VERSION }}
-          builder: ${{ steps.buildx.outputs.name }}
-          cache-from: type=local,src=/tmp/.buildx-cache
-          cache-to: type=local,dest=/tmp/.buildx-cache-new
-
-      - name: Move cache
-        run: |
-          rm -rf /tmp/.buildx-cache
-          mv /tmp/.buildx-cache-new /tmp/.buildx-cache
-
-      - name: Image digest
-        run: |
-          echo ${{ steps.docker_build_caddy.outputs.digest }}
+          cache-from: type=gha
+          cache-to: type=gha,mode=max