Preprocessor #178
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: Preprocessor | |
on: | |
push: | |
branches: ['main'] | |
paths: | |
- '**/preprocessor.*' # 'preprocessor' in any directory and all types | |
- 'sub/*.json' | |
schedule: | |
- cron: '0 */4 * * *' # Runs every 4 hours | |
workflow_dispatch: # Allow manual triggering of the workflow | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
defaults: | |
run: | |
shell: bash -e {0} # Fail the job if any command fails | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch full history | |
submodules: 'recursive' # Include submodules | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# Step 2: Set up PHP | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' # Use PHP 8.2 | |
# Step 3: Run the preprocessor.php script | |
- name: Run preprocessor.php | |
run: php edge/preprocessor.php || exit 1 | |
# Step 4: Configure Git | |
- name: Configure Git | |
run: | | |
git config --local user.name "REvil" | |
git config --local user.email "[email protected]" | |
# Step 5: Commit changes if there are any | |
- name: Commit changes with timestamp | |
run: | | |
git add -A | |
if ! git diff --cached --quiet; then | |
git commit -m "ⅣⅭ Update $(TZ='Asia/Tehran' date '+%H:%M:%S')" \ | |
-m "The list of Cloudflare IPs has been updated" | |
else | |
echo "No changes detected. Skipping commit." | |
fi | |
# Step 6: Push changes | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} |