Skip to content

Commit fe256e7

Browse files
committed
Old action but new workflow
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
1 parent 0910430 commit fe256e7

2 files changed

Lines changed: 20 additions & 27 deletions

File tree

.github/workflows/add-git-trailers.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,33 @@ jobs:
1616
name: Add Git Trailers
1717
if: >-
1818
github.event.pull_request.base.ref == 'main' &&
19-
github.event.review.state == 'approved' &&
20-
(github.event.pull_request.rebaseable == null ||
21-
github.event.pull_request.rebaseable == true)
19+
github.event.review.state == 'approved'
2220
runs-on: ubuntu-22.04
2321
steps:
2422
- name: Harden the runner (Audit all outbound calls)
2523
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
2624
with:
2725
egress-policy: audit
2826

29-
- name: Generate urunc-bot token
30-
id: generate-token
31-
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
32-
with:
33-
app-id: ${{ vars.URUNC_BOT_APP_ID }}
34-
private-key: ${{ secrets.URUNC_BOT_PRIVATE_KEY }}
27+
name: Exit if PR is not rebaseable
28+
if: ${{ github.event.pull_request.rebaseable != null && github.event.pull_request.rebaseable == false }}
29+
run: exit 1
3530

3631
- name: Checkout code
3732
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3833
with:
39-
token: ${{ steps.generate-token.outputs.token }}
4034
fetch-depth: 0
4135
ref: ${{ github.event.pull_request.head.sha }}
4236

37+
- name: Generate urunc-bot token
38+
id: generate-token
39+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
40+
with:
41+
app-id: ${{ vars.URUNC_BOT_APP_ID }}
42+
private-key: ${{ secrets.URUNC_BOT_PRIVATE_KEY }}
43+
4344
- name: Append git trailers
44-
uses: nubificus/git-trailers@e3cefe03237a8a33f12ee41a8194bfb03a4d179b # fix_auto_merge
45+
uses: nubificus/git-trailers@18fd322f3fbfd505b4de728974a4ac1f32f758a7
4546
with:
4647
user_info: .github/contributors.yaml
4748

.github/workflows/pr-merge.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ permissions:
1313
jobs:
1414
add-trailers-and-merge:
1515
if: |
16-
github.event.pull_request.merged == true &&
17-
startsWith(github.event.pull_request.base.ref, 'main-pr')
16+
github.event.pull_request.merged == true
1817
runs-on: ubuntu-latest
1918
permissions:
2019
contents: write
@@ -25,6 +24,10 @@ jobs:
2524
with:
2625
egress-policy: audit
2726

27+
name: Exit if PR is not rebaseable
28+
if: ${{ github.event.pull_request.rebaseable != null && github.event.pull_request.rebaseable == false }}
29+
run: exit 1
30+
2831
- name: Check out repo
2932
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3033
with:
@@ -39,7 +42,7 @@ jobs:
3942
private-key: ${{ secrets.URUNC_BOT_PRIVATE_KEY }}
4043

4144
- name: Append git trailers
42-
uses: nubificus/git-trailers@e3cefe03237a8a33f12ee41a8194bfb03a4d179b # fix_auto_merge
45+
uses: nubificus/git-trailers@18fd322f3fbfd505b4de728974a4ac1f32f758a7
4346
with:
4447
user_info: .github/contributors.yaml
4548

@@ -48,24 +51,13 @@ jobs:
4851
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
4952
PR_BRANCH: ${{ github.event.pull_request.base.ref }}
5053
run: |
51-
PR_NUMBER=${PR_BRANCH#main-pr}
52-
53-
# Use GitHub's API to get issues referenced with closing keywords
54-
CLOSING_ISSUES=$(gh pr view "$PR_NUMBER" --json closingIssuesReferences \
55-
--jq '.closingIssuesReferences[].number' || true)
56-
57-
BODY="This PR was automatically created by GitHub Actions to merge changes from $PR_BRANCH into main."
58-
if [ -n "$CLOSING_ISSUES" ]; then
59-
while IFS= read -r issue; do
60-
BODY="$BODY"$'\n'"Closes #$issue"
61-
done <<< "$CLOSING_ISSUES"
62-
fi
54+
PR_BRANCH=${{ github.event.pull_request.base.ref }}
6355
6456
# Create the pull request
6557
PR_URL=$(gh pr create \
6658
--head "$PR_BRANCH" \
6759
--base main \
6860
--title "Merge External PR: Merge $PR_BRANCH into main" \
69-
--body "$BODY")
61+
--body "This PR was automatically created by GitHub Actions to merge changes from $PR_BRANCH into main.")
7062
7163
gh pr merge "$PR_URL" --rebase --admin --delete-branch

0 commit comments

Comments
 (0)