|
4 | 4 | pull_request: |
5 | 5 | paths: |
6 | 6 | - '_data/conferences.yml' |
7 | | - |
8 | | -permissions: |
9 | | - contents: write |
10 | | - pull-requests: write |
| 7 | + types: |
| 8 | + - closed |
| 9 | + branches: |
| 10 | + - main |
11 | 11 |
|
12 | 12 | jobs: |
13 | | - sort: |
| 13 | + process-merged-pr: |
| 14 | + if: github.event.pull_request.merged == true |
14 | 15 | runs-on: ubuntu-latest |
15 | 16 | steps: |
16 | 17 | - name: Checkout repository |
17 | 18 | uses: actions/checkout@v4 |
18 | | - with: |
19 | | - ref: ${{ github.event.pull_request.head.ref }} |
20 | | - repository: ${{ github.event.pull_request.head.repo.full_name }} |
21 | 19 |
|
22 | 20 | - name: Setup Pixi |
23 | 21 | uses: prefix-dev/[email protected] |
24 | 22 |
|
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 |
29 | 25 | 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 }} |
47 | 28 |
|
48 | | - - name: Setup Pixi |
49 | | - uses: prefix-dev/setup-pixi@v0.8.2 |
| 29 | + # Run your commands |
| 30 | + pixi run sort |
50 | 31 |
|
51 | | - - name: Add contributor and commit if changed |
52 | | - run: | |
53 | 32 | PR_AUTHOR="${{ github.event.pull_request.user.login }}" |
54 | | -
|
55 | 33 | pixi run install |
56 | 34 | pixi run add $PR_AUTHOR conference |
57 | 35 |
|
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 |
59 | 41 | git config --global user.name 'github-actions[bot]' |
60 | 42 | 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 |
64 | 50 | 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