Merge pull request #148 from Dinip/improve-cache-action #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Purge cache on markers update | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
purge-cache: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- 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: | | |
echo FILES_JSON=$(echo '${{ steps.filter.outputs.markers_files }}' | jq '. | map("https://gitcdn.dinip.pt/Dinip/hermitcraft/master/" + .)') >> $GITHUB_ENV | |
- name: Purge Cloudflare cache | |
if: steps.filter.outputs.markers == 'true' | |
run: | | |
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}" \ | |
-d "{\"files\": $FILES_JSON}" \ | |
"https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE_IDENTIFIER }}/purge_cache" |