-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
7 changed files
with
117 additions
and
204 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
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 |
---|---|---|
|
@@ -2,6 +2,9 @@ name: Update hosts | |
|
||
on: | ||
push: | ||
paths: | ||
- 'setHosts.py' | ||
- 'requirements.txt' | ||
schedule: | ||
- cron: '0 */4 * * *' | ||
workflow_dispatch: | ||
|
@@ -22,7 +25,6 @@ jobs: | |
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
|
@@ -34,28 +36,16 @@ jobs: | |
run: | | ||
python -m pip install --upgrade pip | ||
sudo pip install -r requirements.txt | ||
echo "Installed packages:" | ||
sudo pip list | ||
- name: Run hosts update script | ||
run: | | ||
echo "Python version and location:" | ||
python -V | ||
which python | ||
echo "Running script with sudo..." | ||
sudo python SetHosts.py --verbose | ||
sudo python setHosts.py | ||
- 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 | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "更新 hosts" | ||
file_pattern: '.' | ||
commit_user_name: action_bot | ||
commit_user_email: [email protected] | ||
push_options: '--force' |
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
Oops, something went wrong.