CI: build: add job to remove previous ccache cache if already exist
authorChristian Marangi <ansuelsmth@gmail.com>
Sun, 28 May 2023 00:55:26 +0000 (02:55 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Wed, 31 May 2023 11:22:03 +0000 (13:22 +0200)
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 <ansuelsmth@gmail.com>
.github/workflows/build.yml
.github/workflows/coverity.yml
.github/workflows/kernel.yml
.github/workflows/label-kernel.yml
.github/workflows/label-target.yml
.github/workflows/packages.yml
.github/workflows/push-containers.yml
.github/workflows/toolchain.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:
index 10355456321513f005fb1198d561448c759e1b1e..363ce3a29a302090f6adab7372a69c596786ecaf 100644 (file)
@@ -15,6 +15,7 @@ jobs:
     permissions:
       contents: read
       packages: read
+      actions: write
     uses: ./.github/workflows/build.yml
     with:
       container_name: toolchain
index 6be7ef28c2f4e01ca696512b9fffba8eb2f00e1e..d9ab8581c9b455968ce36731b9a8b7335e149b07 100644 (file)
@@ -105,6 +105,7 @@ jobs:
     permissions:
       contents: read
       packages: read
+      actions: write
     strategy:
        fail-fast: False
        matrix:
index 67faaddfcdfce4691e3af905b683d21e00ce66f3..29a9d795588ac3a69e5b9a328f73c005633c78a1 100644 (file)
@@ -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 }}
index 78aea28b106b807ea678b70de5598db7e485f851..610aab026aad43af3e42dd6725a74fafdac76e5e 100644 (file)
@@ -30,6 +30,7 @@ jobs:
     permissions:
       contents: read
       packages: read
+      actions: write
     uses: ./.github/workflows/build.yml
     with:
       container_name: toolchain
index d4d3565cd70b3d481dd6f5656aa28e2554fc71b8..8ab07f1f073c7ef1ac042dca013ceb437e374e45 100644 (file)
@@ -35,6 +35,7 @@ jobs:
     permissions:
       contents: read
       packages: read
+      actions: write
     strategy:
       fail-fast: False
       matrix:
index eb6ffd30c1e648db5bcad75bb9f867b998981f13..1678c5ad4fe3cd872b53ff65c094fa92c42b6eea 100644 (file)
@@ -153,6 +153,7 @@ jobs:
     permissions:
       contents: read
       packages: read
+      actions: write
     strategy:
       fail-fast: False
       matrix:
index 54e31069e6f7d2ea5e75226d5dbfa9fba880a29f..4f4d78f4f8aecf47d56c427c3ab5c6f1ae521867 100644 (file)
@@ -61,6 +61,7 @@ jobs:
     permissions:
       contents: read
       packages: read
+      actions: write
     strategy:
        fail-fast: False
        matrix: