-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add base prepare release pr script
- Loading branch information
1 parent
cdf24b3
commit f2816de
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: 'Prepare release PR' | ||
on: | ||
pull_request: | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
Prepare: | ||
name: 'Prepare release pr' | ||
timeout-minutes: 10 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Git checkout' | ||
uses: actions/checkout@v2 | ||
|
||
# Beginning of yarn setup, keep in sync between all workflows | ||
- name: Use node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2.1.5 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
registry-url: https://registry.npmjs.org/ # Needed for auth | ||
- name: 'Use cached node_modules' | ||
id: cache-modules | ||
uses: actions/cache@v2.1.5 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-v${{ matrix.node-version }}-node_modules-${{ hashFiles('yarn.lock', '**/package.json') }} | ||
- name: 'Find location of global yarn cache' | ||
id: yarn-cache | ||
if: steps.cache-modules.outputs.cache-hit != 'true' | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- name: 'Cache global yarn cache' | ||
uses: actions/cache@v2.1.5 | ||
if: steps.cache-modules.outputs.cache-hit != 'true' | ||
with: | ||
path: ${{ steps.yarn-cache.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: 'Install dependency' | ||
run: yarn install --frozen-lockfile | ||
# End of yarn setup | ||
|
||
- name: 'Build CI scripts' | ||
run: yarn ci:build:scripts | ||
|
||
- name: 'Prepare PR' | ||
uses: actions/github-script@v3 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const { prepareReleasePR } = require(`${process.env.GITHUB_WORKSPACE}/ci/dist/prepareReleasePR.js`) | ||
prepareReleasePR({ github, context }) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
extends: '../.eslintrc.js', | ||
rules: { | ||
'react/display-name': 0, | ||
'no-plusplus': 0, | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export const prepareReleasePR = async ({ github, context }: { github: any; context: any }) => { | ||
const newMessage = ` | ||
👋 Thanks for testing#1! | ||
`; | ||
|
||
const commentInfo = { | ||
...context.repo, | ||
issue_number: context.issue.number, | ||
}; | ||
const signature = 'via JJ GitHub Actions 🇵🇱'; | ||
const comment = { | ||
...commentInfo, | ||
body: `${newMessage}\n\n${signature}`, | ||
}; | ||
|
||
let commentId; | ||
const comments = (await github.issues.listComments(commentInfo)).data; | ||
for (let i = comments.length; i--; ) { | ||
const c = comments[i]; | ||
if (c.user.type === 'Bot' && c.body.includes(signature)) { | ||
commentId = c.id; | ||
break; | ||
} | ||
} | ||
|
||
if (commentId) { | ||
await github.issues.updateComment({ | ||
...context.repo, | ||
comment_id: commentId, | ||
body: comment.body, | ||
}); | ||
} | ||
|
||
if (!commentId) { | ||
await github.issues.createComment(comment); | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true | ||
}, | ||
"include": ["prepareReleasePR.ts"] | ||
} |
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