Skip to content

Commit

Permalink
chore: update the order when checkout branch happen
Browse files Browse the repository at this point in the history
before script will be updating at main branch
cause a conflict when latter try to update the data/* branch
so checkout/create branch first
  • Loading branch information
alantsai authored Jul 12, 2024
1 parent efdaa33 commit 51085ef
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/fetch-copilot-usage-metrics-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ jobs:
fi
- name: Checkout repository
uses: actions/checkout@v2
- name: Fetch and Switch Branch
run: |
echo "Ensuring git fetch to update the local reference..."
git fetch
echo "Checking if branch exists..."
if git show-ref --verify --quiet refs/heads/${{ env.BRANCH_NAME }} || git show-ref --verify --quiet refs/remotes/origin/${{ env.BRANCH_NAME }}; then
echo "Branch exists, switching to it"
git checkout ${{ env.BRANCH_NAME }}
else
echo "Branch does not exist, creating and switching to it"
git checkout -b ${{ env.BRANCH_NAME }}
fi
- name: Set up CURL command base and Fetch data
run: |
if [ "${{ env.AREA }}" == "org" ]; then
Expand Down Expand Up @@ -58,19 +71,7 @@ jobs:
echo "Uncommitted changes detected, stashing..."
git stash push -m "Stashing changes before switching branches"
fi
echo "Ensuring git fetch to update the local reference..."
git fetch
echo "Checking if branch exists..."
if git show-ref --verify --quiet refs/heads/${{ env.BRANCH_NAME }} || git show-ref --verify --quiet refs/remotes/origin/${{ env.BRANCH_NAME }}; then
echo "Branch exists, switching to it"
git checkout ${{ env.BRANCH_NAME }}
else
echo "Branch does not exist, creating and switching to it"
git checkout -b ${{ env.BRANCH_NAME }}
fi
echo "Configuring Git..."
git config --global user.email "bot@githubaction.com"
git config --global user.name "GitHub Action Bot"
Expand All @@ -84,4 +85,4 @@ jobs:
if ! git push origin ${{ env.BRANCH_NAME }}; then
echo "Failed to push changes, checking for issues..."
# Handle specific push failures here, e.g., pull and merge before retrying
fi
fi

0 comments on commit 51085ef

Please sign in to comment.