Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improving the file cloudflare.yml #22

Open
SophiaLi20 opened this issue Dec 29, 2024 · 3 comments · May be fixed by #25
Open

improving the file cloudflare.yml #22

SophiaLi20 opened this issue Dec 29, 2024 · 3 comments · May be fixed by #25
Assignees
Labels
enhancement New feature or request

Comments

@SophiaLi20
Copy link

we can make this metrics/.github/workflows
/get-cloudflare.yml code more enhance for better maintainability, clarity, and functionality

name: Fetch Cloudflare Data

on:
  schedule:
    # Run at 6:00 AM UTC daily
    - cron: '0 6 * * *'

jobs:
  fetch-cloudflare-data:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout Repository
      uses: actions/checkout@v3

    - name: Set up Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '16.x' # Use a more recent Node.js version if supported

    - name: Install Dependencies
      run: npm install

    - name: Fetch Cloudflare Data
      env:
        CLOUDFLARE_ZONE_TAG: ${{ secrets.CLOUDFLARE_ZONE_TAG }}
        CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
        CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
      run: npm run get-cloudflare

    - name: Check for Changes
      run: |
        git status
        if git diff --quiet; then
          echo "No changes detected. Exiting..."
          exit 0
        fi

    - name: Stage and Commit Changes
      run: |
        git config --local user.name "ocf-bot"
        git config --local user.email "[email protected]"
        git add .
        git commit -m "🗃 Add latest Cloudflare data"

    - name: Fetch and Rebase Main
      run: |
        git fetch origin main
        git pull --rebase origin main

    - name: Push Changes to Main
      run: git push origin HEAD:main

The key improvements in this code are :-

  1. Node.js Version: Updated to setup-node@v3 and a newer Node.js version for better support and security.
  2. Check for Changes: Prevents unnecessary commits if there are no changes.
  3. Rebase Workflow: Keeps the local branch in sync with main before pushing changes

This wil help in workflow is up-to-date, efficient, and avoids redundant commits and pushes.

@SophiaLi20 SophiaLi20 added the enhancement New feature or request label Dec 29, 2024
@kairveeehh
Copy link

hii , would like to work on it kindly allow

@SophiaLi20
Copy link
Author

@peterdudfield Could you please assign this issue to @kairveeehh ?

@SophiaLi20
Copy link
Author

Hi @kairveeehh ,
thanks for your interest in working on this issue! I’ve requested the maintainer to assign it to you, since i can't directly do it.

@kairveeehh kairveeehh linked a pull request Mar 4, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants