Skip to content

Commit 322d418

Browse files
committed
ci: simplify cache overwriting
Ref: actions/cache#342 (comment)
1 parent 8ccec37 commit 322d418

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

.github/actions/system/ccache/action.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ inputs:
2222
description: "path for various caches"
2323
required: true
2424
default: ".cache"
25-
GITHUB_TOKEN:
26-
description: "GitHub token for authentication"
27-
required: true
28-
default: "${{ github.token }}"
2925
CCACHE_HASH_FILE_KEY:
3026
description: "Unique cache key for ccache hash file"
3127
required: true
@@ -53,12 +49,13 @@ runs:
5349
5450
echo "export CCACHE_LOGFILE=$GITHUB_WORKSPACE/$ccache_log_file" >> "${{ inputs.CONFIGURATION_PATH_CCACHE }}"
5551
56-
- name: Restore ccache Hash File
52+
- name: ccache restore hash file
5753
uses: actions/cache/restore@v4
5854
with:
5955
path: ${{ inputs.CACHE_PATH }}/ccache_last_hash
6056
key: ${{ inputs.CCACHE_HASH_FILE_KEY }}
61-
57+
restore-keys: |
58+
${{ inputs.CCACHE_HASH_FILE_KEY }}-
6259
6360
- name: ccache update hash file
6461
env:
@@ -97,20 +94,12 @@ runs:
9794
echo "ccache_cache_key=ccache-${{ runner.os }}-$new_hash" >> $GITHUB_ENV
9895
echo "ccache_cache_restore_key=ccache-${{ runner.os }}-$prev_hash" >> $GITHUB_ENV
9996
100-
- name: ccache remove hash file
101-
if: env.ccache_hash_file_changed == 'true'
102-
uses: open-control-systems/gh-action-cache-clear@v0.0.2
103-
with:
104-
PATTERN: "^${{ inputs.CCACHE_HASH_FILE_KEY }}"
105-
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
106-
107-
10897
- name: ccache save hash file
10998
if: env.ccache_hash_file_changed == 'true'
11099
uses: actions/cache/save@v4
111100
with:
112101
path: ${{ inputs.CACHE_PATH }}/ccache_last_hash
113-
key: ${{ inputs.CCACHE_HASH_FILE_KEY }}
102+
key: ${{ inputs.CCACHE_HASH_FILE_KEY }}-${{ github.run_id }}
114103

115104
- name: ccache setup cache
116105
uses: actions/cache@v4

.github/workflows/esp32.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14-
permissions:
15-
# `actions:write` permission is required to delete caches
16-
#
17-
# refs:
18-
# - https://stackoverflow.com/questions/70435286/resource-not-accessible-by-integration-on-github-post-repos-owner-repo-ac
19-
# - https://github.com/actions/cache/blob/6849a6489940f00c2f30c0fb92c6274307ccb58a/tips-and-workarounds.md?plain=1#L57
20-
# - https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#permissions
21-
actions: write
2214
env:
2315
PROJECT_PATH: project
2416
IDF_PATH: esp-idf
@@ -49,7 +41,6 @@ jobs:
4941
- name: system setup ccache
5042
uses: ./project/.github/actions/system/ccache
5143
with:
52-
GITHUB_TOKEN: ${{ github.token }}
5344
PROJECT_PATH: ${{ env.PROJECT_PATH }}
5445
CONTROL_COMPONENTS_PATH: ${{ env.PROJECT_PATH }}
5546
CONFIGURATION_PATH_CCACHE: ${{ env.CONFIGURATION_PATH_CCACHE }}

0 commit comments

Comments
 (0)