Cloudflare Settings Automation #27
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: Cloudflare Settings Automation | |
on: | |
workflow_dispatch: # Allows manual triggering from GitHub Actions UI | |
schedule: | |
- cron: '0 0 * * *' # Runs daily at midnight | |
jobs: | |
apply-settings: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Create and activate virtual environment | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
python -m pip install --upgrade pip | |
pip install --force-reinstall aiohttp pydantic cloudflare tenacity pyyaml | |
shell: bash # Ensure the script runs in a bash shell | |
- name: Verify configuration file | |
run: | | |
source venv/bin/activate | |
if [ ! -f config/cloudflare.yaml ]; then | |
echo "::error::Configuration file not found at config/cloudflare.yaml" | |
exit 1 | |
fi | |
shell: bash # Ensure the script runs in a bash shell | |
- name: Set environment variables | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} | |
CLOUDFLARE_FQDN: ${{ secrets.CLOUDFLARE_FQDN }} | |
run: | | |
source venv/bin/activate | |
echo "Environment variables set." | |
shell: bash # Ensure the script runs in a bash shell | |
- name: Run Cloudflare script | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} | |
CLOUDFLARE_FQDN: ${{ secrets.CLOUDFLARE_FQDN }} | |
run: | | |
source venv/bin/activate | |
python scripts/apply_cloudflare.py --config config/cloudflare.yaml | |
shell: bash # Ensure the script runs in a bash shell | |
- name: Cleanup and feedback | |
if: failure() | |
run: echo "::error::Workflow failed at some steps. Please check the logs." |