uBlock Ads already has this #248
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: Deploy to gh-pages branch | |
on: | |
push: | |
branches: | |
- master | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
publish: | |
permissions: | |
contents: write # for Git to git push | |
name: Publish lists | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone finnish-easylist-addition | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Copy filter lists to gh-pages | |
run: | | |
TMPDIR=$(mktemp -d) | |
git clone --depth=1 https://github.com/finnish-easylist-addition/finnish-easylist-addition.git $TMPDIR | |
cp $TMPDIR/*.txt ./ | |
- name: Patch last-updated field | |
run: | | |
DATE=$(date -Ru) | |
for f in $(ls Finland_adb*.txt); do | |
STAT=$(git diff --numstat $f | sed -r '/^1\s+1\s+/d') | |
if [[ -n $STAT ]]; then | |
sed -ir "0,/^! Last modified: /s/^\(! Last modified: \)%timestamp%/\\1$DATE/" Finland_adb.txt | |
break | |
fi | |
done | |
- name: Commit changes (if any) | |
run: | | |
if [[ -n $(git diff) ]]; then | |
git config user.name "gitHub-actions bot" | |
git config user.email "<>" | |
git add -u ./ | |
git commit -m "Update modified filter lists" | |
git push origin gh-pages | |
fi |