From 935666a5759516ffea95810bd4c42bedf7dcc9f5 Mon Sep 17 00:00:00 2001 From: UjuiUjuMandan <125150101+UjuiUjuMandan@users.noreply.github.com> Date: Mon, 24 Mar 2025 08:35:44 +0000 Subject: [PATCH] sendGFWList.yml --- .github/workflows/sendGFWList.yml | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/sendGFWList.yml diff --git a/.github/workflows/sendGFWList.yml b/.github/workflows/sendGFWList.yml new file mode 100644 index 0000000..e1ba6cd --- /dev/null +++ b/.github/workflows/sendGFWList.yml @@ -0,0 +1,57 @@ +name: send GFWList + +on: + push: + paths: + - 'list.txt' + +jobs: + convert-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y date file git openssl perl + + - name: Sanity check. + run: | + for cmd in date file git openssl perl; do + command -v $cmd >/dev/null 2>&1 || { echo "Error: You must have $cmd command installed!"; exit 1; } + done + + - name: modified by others, commit to local git repository + run: | + git diff --quiet HEAD^ HEAD list.txt || echo "modified=true" >> $GITHUB_ENV + continue-on-error: true + + - name: exit if no changes + if: env.modified != 'true' + run: | + echo "Info: list.txt not modified." + exit 0 + + - name: update date and checksum + run: | + perl addChecksum.pl list.txt || { echo "Error: Failed to update checksum"; exit 1; } + if [ "$(file -b list.txt)" != "ASCII text" ]; then + echo "Error: list.txt invalid, please make sure:" + echo "1. there is no non-ASCII characters;" + echo "2. configure your text editor to use unix style line break." + exit 1 + fi + echo "DATE=$(date)" >> $GITHUB_ENV + + - name: convert to gfwlist.txt + run: | + openssl base64 -in list.txt | tr -d '\r' > gfwlist.txt + + - name: save local changes to git & svn + id: auto-commit-action + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: gfwlist edited ${{ env.DATE }}