Skip to content

Generate AdAway block hosts file #398

Generate AdAway block hosts file

Generate AdAway block hosts file #398

Workflow file for this run

name: Generate AdAway block hosts file
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
transfer:
runs-on: ubuntu-latest
env:
UPSTREAM_REPO_NAME: "privacy-protection-tools/anti-AD"
UPSTREAM_REPO_REF: "master"
UPSTREAM_REPO_PATH: "${{ github.workspace }}/upstream"
OUTPUT_FILE_NAME: "anti-ad-adaway.txt"
steps:
- name: Checkout self repo
uses: actions/checkout@v3
- name: Checkout upstream repo
uses: actions/checkout@v3
with:
repository: ${{ env.UPSTREAM_REPO_NAME }}
ref: ${{ env.UPSTREAM_REPO_REF }}
path: ${{ env.UPSTREAM_REPO_PATH }}
- name: Setup Python
uses: actions/setup-python@v4
- name: Transfer file
run: |
python transfer.py ${{ env.UPSTREAM_REPO_PATH }}/anti-ad-domains.txt ${{ env.OUTPUT_FILE_NAME }}
- name: Get head commit sha of upstream repo
id: get-head-sha
run: |
echo "head_sha=$(cd ${{ env.UPSTREAM_REPO_PATH }} && git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add ${{ env.OUTPUT_FILE_NAME }}
if ! git diff-index --quiet HEAD; then
git commit -m "Sync with upstream ${{ env.UPSTREAM_REPO_NAME }}@${{ steps.get-head-sha.outputs.head_sha }}"
fi
- name: Push changes
uses: ad-m/github-push-action@master