Browse Source

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 years ago
parent
commit
203cc0a7ef

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

@@ -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/[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
         uses: actions/cache/save@v3
         with:

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

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

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

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

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

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

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

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

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

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

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

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

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

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