瀏覽代碼

CI: build: add job to remove previous ccache cache if already exist

Github Actions cache doesn't permit to overwrite cache if it does
already exist. As a trick to refresh and have fresh ccache pool,
delete the ccache cache if it does exist with the help of Github REST
API. An additional permission is needed to access this API. Add this
permittion to each user of the build workflow.

Signed-off-by: Christian Marangi <[email protected]>
Christian Marangi 2 年之前
父節點
當前提交
203cc0a7ef

+ 11 - 0
.github/workflows/build.yml

@@ -136,6 +136,7 @@ jobs:
     permissions:
     permissions:
       contents: read
       contents: read
       packages: read
       packages: read
+      actions: write
 
 
     steps:
     steps:
       - name: Checkout master directory
       - name: Checkout master directory
@@ -475,6 +476,16 @@ jobs:
           name: ${{ inputs.target }}-${{ inputs.subtarget }}-logs
           name: ${{ inputs.target }}-${{ inputs.subtarget }}-logs
           path: "openwrt/logs"
           path: "openwrt/logs"
 
 
+      - name: Delete already present ccache cache
+        if: steps.restore-ccache-cache.outputs.cache-hit == 'true'
+        uses: octokit/[email protected]
+        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
       - name: Save ccache cache
         uses: actions/cache/save@v3
         uses: actions/cache/save@v3
         with:
         with:

+ 1 - 0
.github/workflows/coverity.yml

@@ -15,6 +15,7 @@ jobs:
     permissions:
     permissions:
       contents: read
       contents: read
       packages: read
       packages: read
+      actions: write
     uses: ./.github/workflows/build.yml
     uses: ./.github/workflows/build.yml
     with:
     with:
       container_name: toolchain
       container_name: toolchain

+ 1 - 0
.github/workflows/kernel.yml

@@ -105,6 +105,7 @@ jobs:
     permissions:
     permissions:
       contents: read
       contents: read
       packages: read
       packages: read
+      actions: write
     strategy:
     strategy:
        fail-fast: False
        fail-fast: False
        matrix:
        matrix:

+ 2 - 0
.github/workflows/label-kernel.yml

@@ -30,6 +30,7 @@ jobs:
     permissions:
     permissions:
       contents: read
       contents: read
       packages: read
       packages: read
+      actions: write
     uses: ./.github/workflows/build.yml
     uses: ./.github/workflows/build.yml
     with:
     with:
       container_name: toolchain
       container_name: toolchain
@@ -44,6 +45,7 @@ jobs:
     permissions:
     permissions:
       contents: read
       contents: read
       packages: read
       packages: read
+      actions: write
     uses: ./.github/workflows/check-kernel-patches.yml
     uses: ./.github/workflows/check-kernel-patches.yml
     with:
     with:
       target: ${{ needs.set_target.outputs.target }}
       target: ${{ needs.set_target.outputs.target }}

+ 1 - 0
.github/workflows/label-target.yml

@@ -30,6 +30,7 @@ jobs:
     permissions:
     permissions:
       contents: read
       contents: read
       packages: read
       packages: read
+      actions: write
     uses: ./.github/workflows/build.yml
     uses: ./.github/workflows/build.yml
     with:
     with:
       container_name: toolchain
       container_name: toolchain

+ 1 - 0
.github/workflows/packages.yml

@@ -35,6 +35,7 @@ jobs:
     permissions:
     permissions:
       contents: read
       contents: read
       packages: read
       packages: read
+      actions: write
     strategy:
     strategy:
       fail-fast: False
       fail-fast: False
       matrix:
       matrix:

+ 1 - 0
.github/workflows/push-containers.yml

@@ -153,6 +153,7 @@ jobs:
     permissions:
     permissions:
       contents: read
       contents: read
       packages: read
       packages: read
+      actions: write
     strategy:
     strategy:
       fail-fast: False
       fail-fast: False
       matrix:
       matrix:

+ 1 - 0
.github/workflows/toolchain.yml

@@ -61,6 +61,7 @@ jobs:
     permissions:
     permissions:
       contents: read
       contents: read
       packages: read
       packages: read
+      actions: write
     strategy:
     strategy:
        fail-fast: False
        fail-fast: False
        matrix:
        matrix: