-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2249dd
commit 70b22a0
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Deploy to gh-pages branch | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'RuAdList-uBO.txt' | ||
- 'advblock/**' | ||
- 'css-fixes-experimental.txt' | ||
- 'js-fixes-experimental.txt' | ||
- 'AWRL-non-sync.txt' | ||
- 'tools/RuAdList-uBO.template' | ||
|
||
# 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 RuAdList | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: gh-pages | ||
- name: Generate version string | ||
run: | | ||
TAGNAME=$(date -u "+%Y.%-m.%-d.")$(date -u "+%H*60+%M" | bc) | ||
echo "TAGNAME=$TAGNAME" >> $GITHUB_ENV | ||
echo "Version string is $TAGNAME" | ||
- name: Copy shell script from EasyList/RuAdList | ||
run: | | ||
TMPDIR=$(mktemp -d) | ||
git clone --depth=1 --single-branch --branch=master https://github.com/easylist/ruadlist.git $TMPDIR | ||
cp -v $TMPDIR/tools/make-diffpatch.sh . | ||
cp -v $TMPDIR/tools/update-diffpatches.sh . | ||
- name: Copy filter lists to gh-pages | ||
run: | | ||
TMPFILE=$(mktemp -d) | ||
git clone --depth=1 https://github.com/easylist/ruadlist.git $TMPFILE | ||
pushd $TMPFILE > /dev/null | ||
echo "*** RuAdList: Assembling RuAdList.txt" | ||
node ./tools/make-list.js in=./tools/RuAdList-uBO.template out=./RuAdList-uBO.min.txt minify=1 | ||
popd > /dev/null | ||
cp $TMPFILE/RuAdList-uBO.min.txt RuAdList-uBO.min.txt | ||
- name: Patch last-updated field | ||
run: | | ||
DATE=$(date -Ru) | ||
for f in $(git diff --name-only); do | ||
STAT=$(git diff --numstat $f | sed -r '/^1\s+1\s+/d') | ||
if [[ -n $STAT ]]; then | ||
sed -ir "0,/^! Last updated: /s/^\(! Last updated: \)%timestamp%/\\1$DATE/" $f | ||
else | ||
git checkout -q $f | ||
fi | ||
done | ||
- name: Create new patch | ||
run: | | ||
chmod 755 ./make-diffpatch.sh | ||
./make-diffpatch.sh "${{ env.TAGNAME }}" | ||
- name: Update existing patch | ||
run: | | ||
chmod 755 ./update-diffpatches.sh | ||
./update-diffpatches.sh "${{ env.TAGNAME }}" | ||
- name: Commit changes (if any) | ||
run: | | ||
if [[ -z $(git diff --name-only --cached) ]]; then exit 0; fi | ||
git config user.name "GitHub-Actions" | ||
git config user.email "<>" | ||
git commit -m "Update modified filter lists to ${{ env.TAGNAME }}" | ||
git push origin gh-pages | ||
git tag ${{ env.TAGNAME }} | ||
git push origin ${{ env.TAGNAME }} |