Skip to content

Commit 6d56c1f

Browse files
Merge branch 'main' into main
2 parents e2345f3 + 499d06a commit 6d56c1f

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

.github/workflows/pr-sort.yml

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,63 @@ on:
44
pull_request:
55
paths:
66
- '_data/conferences.yml'
7-
8-
permissions:
9-
contents: write
10-
pull-requests: write
7+
types:
8+
- closed
9+
branches:
10+
- main
1111

1212
jobs:
13-
sort:
13+
process-merged-pr:
14+
if: github.event.pull_request.merged == true
1415
runs-on: ubuntu-latest
1516
steps:
1617
- name: Checkout repository
1718
uses: actions/checkout@v4
18-
with:
19-
ref: ${{ github.event.pull_request.head.ref }}
20-
repository: ${{ github.event.pull_request.head.repo.full_name }}
2119

2220
- name: Setup Pixi
2321
uses: prefix-dev/[email protected]
2422

25-
- name: Run sort command
26-
run: pixi run sort
27-
28-
- name: Check and commit sort changes
23+
- name: Create changes
24+
id: changes
2925
run: |
30-
if ! git diff --exit-code; then
31-
git config --global user.name 'github-actions[bot]'
32-
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
33-
git add _data/*
34-
git commit -m "chore: sort conferences"
35-
git push
36-
fi
37-
38-
add-contributor:
39-
runs-on: ubuntu-latest
40-
needs: sort
41-
steps:
42-
- name: Checkout repository
43-
uses: actions/checkout@v4
44-
with:
45-
ref: ${{ github.event.pull_request.head.ref }}
46-
repository: ${{ github.event.pull_request.head.repo.full_name }}
26+
# Create a new branch
27+
git checkout -b automated-updates-${{ github.event.pull_request.number }}
4728
48-
- name: Setup Pixi
49-
uses: prefix-dev/setup-pixi@v0.8.2
29+
# Run your commands
30+
pixi run sort
5031
51-
- name: Add contributor and commit if changed
52-
run: |
5332
PR_AUTHOR="${{ github.event.pull_request.user.login }}"
54-
5533
pixi run install
5634
pixi run add $PR_AUTHOR conference
5735
58-
if ! git diff --exit-code; then
36+
# Check if there are changes
37+
if ! git diff --quiet; then
38+
echo "has_changes=true" >> $GITHUB_OUTPUT
39+
40+
# Stage and commit changes
5941
git config --global user.name 'github-actions[bot]'
6042
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
61-
git add .all-contributorsrc README.md CONTRBUTING.md
62-
git commit -m "docs: add $PR_AUTHOR as contributor for conferences"
63-
git push
43+
git add _data/* .all-contributorsrc README.md CONTRBUTING.md
44+
git commit -m "chore: post-merge updates
45+
46+
* Sort conferences
47+
* Add $PR_AUTHOR as contributor"
48+
else
49+
echo "has_changes=false" >> $GITHUB_OUTPUT
6450
fi
51+
52+
- name: Create Pull Request
53+
if: steps.changes.outputs.has_changes == 'true'
54+
uses: peter-evans/create-pull-request@v6
55+
with:
56+
title: 'Automated updates from PR #${{ github.event.pull_request.number }}'
57+
body: |
58+
This PR was automatically created after merging #${{ github.event.pull_request.number }}
59+
60+
Changes include:
61+
- Sorted conferences
62+
- Added @${{ github.event.pull_request.user.login }} as contributor
63+
64+
Please review and merge these automated updates.
65+
branch: automated-updates-${{ github.event.pull_request.number }}
66+
delete-branch: true

0 commit comments

Comments
 (0)