Skip to content

Commit 401a77c

Browse files
Timna BrownTimna Brown
authored andcommitted
Fix workflow branch checkout conflicts
1 parent 38b03b1 commit 401a77c

3 files changed

Lines changed: 7 additions & 15 deletions

File tree

.github/workflows/update-md-date.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ jobs:
2525
with:
2626
python-version: '3.x'
2727

28-
- name: Install dependencies
29-
run: pip install python-dateutil
30-
3128
- name: Configure Git
3229
run: |
3330
git config --global user.email "github-actions[bot]@users.noreply.github.com"

.github/workflows/update_date.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import subprocess
32
from datetime import datetime, timezone
43

@@ -44,6 +43,3 @@ def update_date_in_file(file_path):
4443
print(f"Updating file: {file_path}") # Debugging: Print the file being updated
4544
update_date_in_file(file_path)
4645

47-
# Add and commit changes
48-
subprocess.run(['git', 'add', '-A'])
49-
subprocess.run(['git', 'commit', '-m', 'Update last modified date in Markdown files'])

.github/workflows/use-visitor-counter.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 0
24+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
2425

2526
- name: Shallow clone visitor counter logic
2627
run: git clone --depth=1 https://github.com/brown9804/github-visitor-counter.git
@@ -63,24 +64,22 @@ jobs:
6364
env:
6465
TOKEN: ${{ secrets.GITHUB_TOKEN }}
6566
run: |
66-
git fetch origin
67-
git checkout ${{ github.head_ref }}
68-
git pull origin ${{ github.head_ref }} || echo "No merge needed"
67+
BRANCH="${{ github.head_ref }}"
68+
git pull origin "$BRANCH" || echo "No merge needed"
6969
git add -A
7070
git commit -m "Update visitor count" || echo "No changes to commit"
7171
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
72-
git push origin HEAD:${{ github.head_ref }}
72+
git push origin HEAD:"$BRANCH"
7373
7474
# Commit and push logic for non-PR events (merge, not rebase)
7575
- name: Commit and push changes (non-PR)
7676
if: github.event_name != 'pull_request'
7777
env:
7878
TOKEN: ${{ secrets.GITHUB_TOKEN }}
7979
run: |
80-
git fetch origin
81-
git checkout ${{ github.ref_name }} || git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
82-
git pull origin ${{ github.ref_name }} || echo "No merge needed"
80+
BRANCH="${{ github.ref_name }}"
81+
git pull origin "$BRANCH" || echo "No merge needed"
8382
git add -A
8483
git commit -m "Update visitor count" || echo "No changes to commit"
8584
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
86-
git push origin HEAD:${{ github.ref_name }}
85+
git push origin HEAD:"$BRANCH"

0 commit comments

Comments
 (0)