CI: build: add job to remove previous ccache cache if already exist
[openwrt/openwrt.git] / .github / workflows / build.yml
index 31da7fa7ab5290778c9bb0eeaae5ae45ddb0c9c1..7ce8a7c034e70d8f3f9448ba4f2ff88d3660837b 100644 (file)
@@ -136,6 +136,7 @@ jobs:
     permissions:
       contents: read
       packages: read
+      actions: write
 
     steps:
       - name: Checkout master directory
@@ -475,6 +476,16 @@ jobs:
           name: ${{ inputs.target }}-${{ inputs.subtarget }}-logs
           path: "openwrt/logs"
 
+      - name: Delete already present ccache cache
+        if: steps.restore-ccache-cache.outputs.cache-hit == 'true'
+        uses: octokit/request-action@v2.x
+        with:
+          route: DELETE /repos/{repository}/actions/caches?key={key}
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          INPUT_REPOSITORY: ${{ github.repository }}
+          INPUT_KEY: ${{ steps.restore-ccache-cache.outputs.cache-primary-key }}
+
       - name: Save ccache cache
         uses: actions/cache/save@v3
         with: