Skip to content

Update hosts

Update hosts #3

Workflow file for this run

name: Update hosts
on:
push:
paths:
- 'setHosts.py'
- 'requirements.txt'
schedule:
- cron: '0 */4 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
update-hosts:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# 添加详细输出以便调试
pip install -r requirements.txt -v
# 验证安装
pip list | grep dns
- name: Run hosts update script
run: |
# 添加详细输出以便调试
python -V
which python
sudo -E python setHosts.py --verbose
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "action_bot"
if [[ -n $(git status -s) ]]; then
git add .
git commit -m "chore: update hosts content [skip ci]"
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
else
echo "No changes to commit"
fi