Skip to content

Commit

Permalink
Merge pull request #148 from Dinip/improve-cache-action
Browse files Browse the repository at this point in the history
Improve cache action
  • Loading branch information
Dinip authored Mar 24, 2024
2 parents a7a50c1 + a4eceac commit 5e624b7
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/purge-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get modified markers.js files
- name: Filter markers.js files
uses: dorny/paths-filter@v3
id: filter
with:
list-files: json
filters: |
markers:
- '**/markers.js'
- name: Format files list
id: format
if: steps.filter.outputs.markers == 'true'
run: |
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'markers.js$' | while read file; do
echo "https://gitcdn.dinip.pt/Dinip/hermitcraft/master/$file"
done > modified_files.txt
if [ -s modified_files.txt ]; then
echo "FILES_JSON=$(cat modified_files.txt | jq -R . | jq -cs .)" >> $GITHUB_ENV
else
echo "FILES_JSON=[]" >> $GITHUB_ENV
fi
echo FILES_JSON=$(echo '${{ steps.filter.outputs.markers_files }}' | jq '. | map("https://gitcdn.dinip.pt/Dinip/hermitcraft/master/" + .)') >> $GITHUB_ENV
- name: Files to purge
run: echo $FILES_JSON | jq .

- name: Purge Cloudflare cache
if: env.FILES_JSON != '[]'
if: steps.filter.outputs.markers == 'true'
run: |
curl -X POST \
-H "Content-Type: application/json" \
Expand Down

0 comments on commit 5e624b7

Please sign in to comment.