mirror of
https://github.com/tiennm99/open-domains.git
synced 2026-10-15 10:15:31 +00:00
Create helper.yml
This commit is contained in:
1 parent
264edf231d
commit
d753a45961
1 file changed
+48
@@ -0,0 +1,48 @@
|
||||
name: Post Merged.md on PR Close
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
|
||||
jobs:
|
||||
post-merged-md:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Check if the PR was merged
|
||||
- id: create_token
|
||||
uses: tibdex/github-app-token@v2
|
||||
with:
|
||||
app_id: ${{ secrets.APP_ID }}
|
||||
private_key: ${{ secrets.PRIVATE_KEY }}
|
||||
|
||||
- name: Check if PR was merged
|
||||
id: pr-merge-check
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
return context.payload.pull_request.merged
|
||||
|
||||
# Fetch merged.md content if PR was merged
|
||||
- name: Fetch merged.md content
|
||||
if: steps.pr-merge-check.outputs.result == 'true'
|
||||
run: |
|
||||
curl -o merged.md https://raw.githubusercontent.com/open-domains/.github/main/merged.md
|
||||
|
||||
# Post the content of merged.md as a comment using the custom token
|
||||
- name: Post comment on PR
|
||||
if: steps.pr-merge-check.outputs.result == 'true'
|
||||
uses: actions/github-script@v6
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const content = fs.readFileSync('merged.md', 'utf8');
|
||||
github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: content
|
||||
});
|
||||
Reference in new issue
Block a user