CI #11
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: CI | |
on: | |
schedule: | |
- cron: "0 22 * * 6" | |
push: | |
branches: | |
- master | |
paths: | |
- '.github/workflows/*.yml' | |
- 'rules.txt' | |
pull_request: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Set variables | |
run: | | |
echo "RELEASE_NAME=update on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- name: Upgrade pip and install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install genpac | |
- name: Get current time | |
uses: josStorer/get-current-time@v2 | |
id: time | |
with: | |
format: yyyy-MM-DD | |
- name: Download GFWLIST file | |
run: curl -O https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt | |
- name: Force commit changes to gfwlist.txt | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add gfwlist.txt | |
git commit -m "chore: ${{ steps.time.outputs.formattedTime }} force update ./gfwlist.txt" || echo "No changes to commit" | |
- name: Download AWAvenue-Ads-Rule file | |
run: curl -O https://raw.githubusercontent.com/TG-Twilight/AWAvenue-Ads-Rule/main/AWAvenue-Ads-Rule.txt | |
- name: Force commit changes to AWAvenue-Ads-Rule.txt | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add AWAvenue-Ads-Rule.txt | |
git commit -m "chore: ${{ steps.time.outputs.formattedTime }} force update ./AWAvenue-Ads-Rule.txt" || echo "No changes to commit" | |
- name: Generate configuration files | |
run: | | |
mkdir -p output | |
genpac --format=pac --pac-proxy "__PROXY__" --gfwlist-local='./gfwlist.txt' --user-rule-from './rules.txt,./AWAvenue-Ads-Rule.txt' -o ./pac/pac.txt | |
- name: Commit changes to pac.txt | |
uses: EndBug/add-and-commit@v9 | |
if: github.event_name != 'pull_request' | |
with: | |
message: "chore: ${{ steps.time.outputs.formattedTime }} update ./pac/pac.txt" | |
add: ./pac/pac.txt | |
author_name: "github-actions[bot]" | |
author_email: "github-actions[bot]@users.noreply.github.com" | |
- name: Delete previous release and tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
previous_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | |
if [ -n "$previous_tag" ]; then | |
echo "Deleting previous tag: $previous_tag" | |
git push --delete origin $previous_tag | |
gh release delete $previous_tag --repo $GITHUB_REPOSITORY --yes | |
fi | |
- name: Release and upload assets | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
release_name: ${{ env.RELEASE_NAME }} | |
tag: ${{ env.TAG_NAME }} | |
file_glob: true | |
file: ./pac/* |