Skip to content

πŸ”€ FF Merge - PR # #6

πŸ”€ FF Merge - PR #

πŸ”€ FF Merge - PR # #6

name: ff-merge-labeler
run-name: 'πŸ”€ FF Merge - PR #${{ github.event.issue_comment.issue.id }}'
on:
issue_comment:
types:
- created
permissions:
contents: read
jobs:
check_comment:
name: Check FF-Merge Comment
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
steps:
- name: Debug Event
uses: actions/[email protected]
with:
script: |
console.log("GH_CTX_EVENT:", ${{ github.event }});
console.log("GH_CTX_ISSUE_COMMENT:", ${{ github.event.pull_request }});
console.log("GS_CTX_EVENT:", context.event);
console.log("GS_CTX_PAYLOAD :", context.payload);
- name: Check Comment Author πŸ•΅οΈ
id: ff_merge_check_valid_commentor
shell: bash
run: |
if [ ${{ github.event.issue_comment.comment.author_association }} == 'MEMBER' ]; then
echo "βœ… The comment author is a member of the organization."
echo "valid_commentor=1" >> $GITHUB_OUTPUT
else
echo "❌ The comment author is not a member of the organization. (Expected: MEMBER)"
echo "valid_commentor=0" >> $GITHUB_OUTPUT
fi;
- name: Check Comment Content πŸ“
id: ff_merge_check_comment_content
if: ${{ success() }}
shell: bash
run: |
if [ ${{ github.event.issue_comment.comment.body }} == '/ff-merge' ]; then
echo "βœ… The comment content is valid."
echo "valid_comment=1" >> $GITHUB_OUTPUT
else
echo "❌ The comment content is invalid. (Expected: /ff-merge)"
echo "valid_comment=0" >> $GITHUB_OUTPUT
fi;
- name: Check Issue Labels 🏷️
id: ff_merge_check_issue_labels
if: ${{ success() }}
shell: bash
run: |
if [ $(echo ${{ github.event.issue.labels }} | grep -c 'ff-merge') -eq 0 ]; then
echo "❌ The issue does not have the 'fast-forward-merge' label."
echo "valid_label=0" >> $GITHUB_OUTPUT
else
echo "βœ… The issue has the 'fast-forward-merge' label."
echo "valid_label=1" >> $GITHUB_OUTPUT
fi;
exec_ff_merge:
name: Execute Fast-Forward Merge
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
needs: check_comment
if: ${{ needs.check_comment.outputs.valid_commentor == '1' && needs.check_comment.outputs.valid_comment == '1' }}
steps:
- name: Checkout πŸ’»
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Lock PR πŸ”’
uses: actions/[email protected]
id: lock_pr
with:
script: |
await github.rest.issues.lock({
'owner': context.repo.owner,
'repo': context.repo.repo,
'issue_number': context.issue.number,
'lock_reason': 'resolved',
});
conosle.info('PR locked:', ${{ github.event.issue_comment.issue.html_url }});
- name: Fast-Forward Merge πŸš€
if: ${{ success() }}
run: |
echo "βœ… Fast-Forward Merge ready."