Skip to content

🏁 RoSctober 2024: The Open Source Developer Challenge is about to start #7

🏁 RoSctober 2024: The Open Source Developer Challenge is about to start

🏁 RoSctober 2024: The Open Source Developer Challenge is about to start #7

Workflow file for this run

name: Fast-forward merge
on:
issue_comment:
types: [created, edited]
jobs:
fast_forward:
name: Fast-forward merge
runs-on: ubuntu-latest
if: |
github.event.issue.pull_request &&
github.event.issue.state == 'open' &&
(
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'
) &&
github.event.comment.body == '/fast-forward-merge'
permissions:
actions: write
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Minimize calling comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.graphql(`mutation { minimizeComment(input: { subjectId: "${context.payload.comment.node_id}", classifier: OUTDATED }) { clientMutationId } }`)
const { data: comments } = await github.rest.issues.listComments({
...context.repo,
issue_number: ${{ github.event.issue.number }},
});
for (const comment of comments) {
if (comment.user.login === 'github-actions[bot]' && comment.body.startsWith('Failure merging:')) {
await github.graphql(`mutation { minimizeComment(input: { subjectId: "${comment.node_id}", classifier: OUTDATED }) { clientMutationId } }`)
}
}
- name: Checkout pull request
id: pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ github.event.issue.number }}
echo "base_ref=$(gh pr view ${{ github.event.issue.number }} --json baseRefName)" >> $GITHUB_OUTPUT
- name: Fast-forward merge
run: |
export PR_COMMIT=$(git rev-parse HEAD)
git checkout ${{ fromJSON(steps.pr.outputs.base_ref).baseRefName }}
git merge --ff-only "$PR_COMMIT" 2>output.log
git push origin ${{ fromJSON(steps.pr.outputs.base_ref).baseRefName }} 2>output.log
- name: Post errors
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment ${{ github.event.issue.number }} -b "Failure merging:
\`\`\`
$(cat output.log)
\`\`\`"
- name: Run CI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run "Coverage & Documentation" -r ${{ fromJSON(steps.pr.outputs.base_ref).baseRefName }}