PSAPs Blog Post #11
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: New Issue (Create Blog Post) | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
open-pr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: π¬ Update status | |
id: update_status | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const response = await github.rest.reactions.createForIssue({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue.number, | |
content: 'eyes' | |
}); | |
return response.data.id; | |
- name: π¬ Check actor | |
uses: tspascoal/get-user-teams-membership@v3 | |
id: checkUserMember | |
with: | |
username: ${{ github.actor }} | |
team: committers | |
GITHUB_TOKEN: ${{ secrets.ORG_READ_PAT }} | |
- name: π Stop if not member | |
if: ${{ steps.checkUserMember.outputs.isTeamMember == false }} | |
run: | | |
echo "You cannot run this job." | |
exit 86 | |
- name: β¬οΈ Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- name: β Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
cache: npm | |
- name: π¦ Install script dependencies | |
working-directory: scripts | |
run: npm install | |
- name: π Create Blog Post | |
working-directory: scripts | |
run: node new-blog.mjs ${{ github.event.issue.number }} | |
- name: π Create Pull Request | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: 'feat: create new blog post' | |
title: 'feat: create new blog post' | |
body: | | |
This PR was automatically created by the "Issue opened (new blog)" workflow. | |
closes #${{ github.event.issue.number}} | |
branch: feat/new-blog-post-${{ github.event.issue.number }} | |
draft: true | |
- name: ποΈ Remove reaction | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.reactions.deleteForIssue({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue.number, | |
reaction_id: ${{ steps.update_status.outputs.result }} | |
}) | |
- name: β Set complete reaction | |
uses: actions/github-script@v7 | |
if: ${{ steps.cpr.outputs.pull-request-number }} | |
with: | |
script: | | |
github.rest.reactions.createForIssue({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue.number, | |
content: 'rocket' | |
}); |