Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cache action #148

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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