@@ -192,55 +192,54 @@ jobs:
192192 echo "has_changes=false" >> $GITHUB_OUTPUT
193193 fi
194194
195- - name : 💾 Create and Merge Pull Request
195+ - name : 💾 Create Pull Request
196196 if : steps.changes.outputs.has_changes == 'true'
197+ id : create_pr
198+ uses : peter-evans/create-pull-request@v6
199+ with :
200+ token : ${{ secrets.GITHUB_TOKEN }}
201+ commit-message : " 🏆 Auto-update contributor statistics"
202+ committer : " github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
203+ author : " github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
204+ branch : update-contributors-${{ github.run_number }}
205+ delete-branch : true
206+ title : " 🏆 Update Contributor Statistics"
207+ body : |
208+ ## 🏆 Automated Contributor Statistics Update
209+
210+ This PR automatically updates:
211+ - 👥 Contributors list in README.md
212+ - 📊 Language statistics
213+ - 📅 Last modified date in HALL_OF_FAME.md
214+
215+ ### Changes
216+ - Updated contributor avatars and information
217+ - Refreshed language file counts
218+ - Updated timestamp
219+
220+ **Auto-generated by GitHub Actions** 🤖
221+ ${{ github.event_name == 'pull_request' && format('**Triggered by PR #{0}** by @{1}', github.event.pull_request.number, github.event.pull_request.user.login) || '**Triggered by push to main**' }}
222+ labels : |
223+ documentation
224+ automated
225+ bot
226+ assignees : ${{ github.repository_owner }}
227+
228+ - name : 🔄 Enable Auto-Merge
229+ if : steps.changes.outputs.has_changes == 'true' && steps.create_pr.outputs.pull-request-number != ''
197230 env :
198231 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
199232 run : |
200- # Configure git
201- git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
202- git config --local user.name "github-actions[bot]"
203-
204- # Create a new branch
205- BRANCH_NAME="update-contributors-$(date +%s)"
206- git checkout -b $BRANCH_NAME
207-
208- # Add and commit changes
209- git add README.md HALL_OF_FAME.md
210- git commit -m "🏆 Auto-update contributor statistics"
211-
212- # Push the branch
213- git push origin $BRANCH_NAME
214-
215- # Create pull request
216- PR_URL=$(gh pr create \
217- --title "🏆 Update Contributor Statistics" \
218- --body "## 🏆 Automated Contributor Statistics Update
219-
220- This PR automatically updates:
221- - 👥 Contributors list in README.md
222- - 📊 Language statistics
223- - 📅 Last modified date in HALL_OF_FAME.md
224-
225- ### Changes
226- - Updated contributor avatars and information
227- - Refreshed language file counts
228- - Updated timestamp
229-
230- **Auto-generated by GitHub Actions** 🤖
231- **Triggered by PR #${{ github.event.pull_request.number }}**" \
232- --base main \
233- --head $BRANCH_NAME)
234-
235- echo "✅ Pull request created: $PR_URL"
236-
237- # Get PR number
238- PR_NUMBER=$(echo $PR_URL | grep -oP '\d+$')
239-
240- # Enable auto-merge
241- gh pr merge $PR_NUMBER --auto --squash
242-
243- echo "✅ Auto-merge enabled for PR #$PR_NUMBER"
233+ PR_NUMBER="${{ steps.create_pr.outputs.pull-request-number }}"
234+ echo "🔄 Attempting to enable auto-merge for PR #$PR_NUMBER..."
235+
236+ # Try to enable auto-merge (will fail if not enabled in repo settings)
237+ if gh pr merge $PR_NUMBER --auto --squash 2>/dev/null; then
238+ echo "✅ Auto-merge enabled for PR #$PR_NUMBER"
239+ else
240+ echo "⚠️ Could not enable auto-merge. Please enable 'Allow auto-merge' in repository settings."
241+ echo "📋 PR created: https://github.com/${{ github.repository }}/pull/$PR_NUMBER"
242+ fi
244243
245244 - name : 📋 Generate summary
246245 if : steps.changes.outputs.has_changes == 'true'
@@ -250,11 +249,20 @@ jobs:
250249 echo ""
251250 echo "📊 Action Taken:"
252251 echo " ✅ Created PR with contributor updates"
253- echo " 🔄 Auto-merge enabled"
254- echo " 📅 Triggered by: PR #${{ github.event.pull_request.number }}"
255- echo " 👤 Contributor: @${{ github.event.pull_request.user.login }}"
252+
253+ if [ -n "${{ steps.create_pr.outputs.pull-request-number }}" ]; then
254+ echo " 🔗 PR #${{ steps.create_pr.outputs.pull-request-number }}"
255+ echo " 📎 URL: ${{ steps.create_pr.outputs.pull-request-url }}"
256+ fi
257+
258+ if [ "${{ github.event_name }}" == "pull_request" ]; then
259+ echo " 📅 Triggered by: PR #${{ github.event.pull_request.number }}"
260+ echo " 👤 Contributor: @${{ github.event.pull_request.user.login }}"
261+ else
262+ echo " 📅 Triggered by: Push to main"
263+ fi
256264 echo ""
257- echo "🎉 Contributor statistics will be updated once PR is auto-merged !"
265+ echo "🎉 Please review and merge the PR to apply contributor updates !"
258266
259267 - name : 📋 Generate summary (no changes)
260268 if : steps.changes.outputs.has_changes == 'false'
0 commit comments