π FF Merge - PR # #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |