Update Cloud2BR organization references #266
Workflow file for this run
This file contains hidden or 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: Use Visitor Counter Logic | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: # Allows manual triggering | |
| # schedule: | |
| # - cron: '0 0 * * *' # Runs daily at midnight | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| update-visitor-count: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout current repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Run visitor counter logic (updates markdown badges and metrics.json) | |
| run: node .github/scripts/update_repo_views_counter.js | |
| env: | |
| TRAFFIC_TOKEN: ${{ secrets.TRAFFIC_TOKEN }} | |
| REPO: ${{ github.repository }} | |
| - name: Configure Git author | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # Commit and push logic for PR events (merge, not rebase) | |
| - name: Commit and push changes (PR) | |
| if: github.event_name == 'pull_request' | |
| env: | |
| TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git fetch origin | |
| git checkout ${{ github.head_ref }} | |
| git pull origin ${{ github.head_ref }} || echo "No merge needed" | |
| git add -A | |
| git commit -m "Update visitor count" || echo "No changes to commit" | |
| git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }} | |
| git push origin HEAD:${{ github.head_ref }} | |
| # Commit and push logic for non-PR events (merge, not rebase) | |
| - name: Commit and push changes (non-PR) | |
| if: github.event_name != 'pull_request' | |
| env: | |
| TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git fetch origin | |
| git checkout ${{ github.ref_name }} || git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }} | |
| git pull origin ${{ github.ref_name }} || echo "No merge needed" | |
| git add -A | |
| git commit -m "Update visitor count" || echo "No changes to commit" | |
| git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }} | |
| git push origin HEAD:${{ github.ref_name }} |