Skip to content

Commit

Permalink
test changes for upstreaming (#9)
Browse files Browse the repository at this point in the history
Final tune ups
  • Loading branch information
alaviss authored Apr 22, 2023
1 parent e0923fb commit 251ac19
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
37 changes: 15 additions & 22 deletions .github/workflows/merge-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ on:
types: [merge-command]

permissions:
contents: write
pull-requests: write

concurrency: merge-handler-${{ github.event.client_payload.pull_request.node_id || github.run_id }}

jobs:
merge:
if: github.event.client_payload.pull_request != null

name: Trim description and merge

runs-on: ubuntu-latest

steps:
- id: pr-data
name: Get PR data and trim PR body
Expand Down Expand Up @@ -67,24 +63,31 @@ jobs:
- if: steps.pr-data.outputs.run
id: find-comment
name: Find previously generated informational comment
uses: peter-evans/find-comment@v2
with:
issue-number: ${{ github.event.client_payload.pull_request.number }}
comment-author: github-actions[bot]
body-includes: <!-- /merge info comment -->
direction: last

- if: steps.pr-data.outputs.run && !(steps.find-comment.outputs.comment-id && steps.pr-data.outputs.body-tail == '')
# Only update the comment if there's a tail. This prevents the
# tail from being replaced due to multiple /merge calls.
- if: >-
steps.pr-data.outputs.run
&& !(steps.find-comment.outputs.comment-id
&& steps.pr-data.outputs.body-tail == '')
name: Create or update informational comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.client_payload.pull_request.number }}
body: |
<!-- /merge info comment -->
<!-- Autogenerated by merge-command. DO NOT EDIT -->
Merge requested by: @${{ github.event.client_payload.github.payload.comment.user.login }}
Contents after the first section break of this PR's description has been removed and preserved below:
Contents after the first section break of the PR description has been removed and preserved below:
---
Expand All @@ -95,25 +98,13 @@ jobs:
- if: steps.pr-data.outputs.run && steps.pr-data.outputs.update-body
name: Update PR description
uses: actions/github-script@v6
env:
PR_URL: ${{ github.event.client_payload.pull_request.html_url }}
NEW_PR_BODY: ${{ steps.pr-data.outputs.body }}
with:
script: |
const pull_id = context.payload.client_payload.pull_request.node_id;
const update = `mutation ($input: UpdatePullRequestInput!) {
updatePullRequest(input: $input) {
clientMutationId
}
}`;
await github.graphql(update, {
input: {
pullRequestId: pull_id,
body: process.env.NEW_PR_BODY
}
});
GH_TOKEN: ${{ github.token }}
run: gh pr edit "$PR_URL" --body "$NEW_PR_BODY"

# An app token is required for CI to trigger
- if: steps.pr-data.outputs.run
id: token
name: Create app token for merges
Expand All @@ -122,6 +113,8 @@ jobs:
app_id: ${{ secrets.CHORE_APP_ID }}
private_key: ${{ secrets.CHORE_APP_KEY }}

# TODO: Switch to GitHub CLI once
# https://github.com/cli/cli/issues/7213 is solved.
- if: steps.pr-data.outputs.run
name: Queue for merging
uses: actions/github-script@v6
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/slash-commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ on:
- created

jobs:
dispatch:
name: Dispatch command
dispatch_pr:
if: github.event.issue.pull_request
name: Dispatch on Pull Request comments
runs-on: ubuntu-latest
steps:
- id: token
Expand Down

0 comments on commit 251ac19

Please sign in to comment.