mirror of
https://github.com/zhigang1992/connect.git
synced 2026-04-29 01:45:38 +08:00
fix: write custom comment plugin
This commit is contained in:
committed by
Thomas Osmonson
parent
7210fa9022
commit
ed52e55928
20
.github/workflows/comment-on-pr.yml
vendored
20
.github/workflows/comment-on-pr.yml
vendored
@@ -1,20 +0,0 @@
|
||||
name: comment-on-pr
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
comment_on_pr:
|
||||
name: Link to demo app
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: get PR number
|
||||
id: pr_number
|
||||
run: echo "::set-output name=pr_number::$(jq --raw-output .pull_request.number $GITHUB_EVENT_PATH)"
|
||||
- name: comment PR
|
||||
uses: unsplash/comment-on-pr@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ steps.pr_number.outputs.pr_number }}
|
||||
with:
|
||||
msg: "Hey! If you'd like to test out the changes in this PR, check out our demo app. https://deploy-preview-${{ steps.pr_number.outputs.pr_number }}--authenticator-demo.netlify.com/"
|
||||
50
.github/workflows/deploy-apps.yml
vendored
50
.github/workflows/deploy-apps.yml
vendored
@@ -34,16 +34,17 @@ jobs:
|
||||
with:
|
||||
source: 'packages/app/vercel.json'
|
||||
target: 'packages/app/dist/vercel.json'
|
||||
- uses: amondnet/vercel-action@v19.0.1+1
|
||||
- name: Deploy Blockstack App with Vercel
|
||||
uses: amondnet/vercel-action@v19.0.1+1
|
||||
id: vercel-deployment-blockstack-app
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
||||
vercel-org-id: ${{ secrets.ORG_ID }}
|
||||
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_APP }}
|
||||
scope: ${{ secrets.VERCEL_SCOPE }}
|
||||
working-directory: packages/app/dist
|
||||
github-comment: false
|
||||
- name: Build Blockstack Test App
|
||||
env:
|
||||
AUTH_ORIGIN: ${{ steps.vercel-deployment-blockstack-app.outputs.preview-url }}
|
||||
@@ -54,13 +55,54 @@ jobs:
|
||||
with:
|
||||
source: 'packages/test-app/vercel.json'
|
||||
target: 'packages/test-app/dist/vercel.json'
|
||||
- uses: amondnet/vercel-action@v19.0.1+1
|
||||
- name: Deploy Blockstack Test App with Vercel
|
||||
uses: amondnet/vercel-action@v19.0.1+1
|
||||
id: vercel-deployment-blockstack-test-app
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
||||
vercel-org-id: ${{ secrets.ORG_ID }}
|
||||
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_TEST_APP }}
|
||||
scope: ${{ secrets.VERCEL_SCOPE }}
|
||||
working-directory: packages/test-app/dist
|
||||
github-comment: false
|
||||
- name: Comment on PR
|
||||
uses: actions/github-script@v2
|
||||
id: comment
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const firstLine = `Deploy previews for _${{ steps.vercel-deployment-blockstack-app.outputs.preview-name }}_ and _${{ steps.vercel-deployment-blockstack-test-app.outputs.preview-name }}_ are ready!`;
|
||||
const { data } = await github.issues.listComments({
|
||||
...context.repo,
|
||||
issue_number: context.issue.number,
|
||||
});
|
||||
const vercelPreviewURLComment = data.find((comment) =>
|
||||
comment.body.includes(firstLine)
|
||||
);
|
||||
const commentId = vercelPreviewURLComment && vercelPreviewURLComment.id || undefined;
|
||||
const commentBody = `
|
||||
#### Deploy previews
|
||||
${firstLine}
|
||||
|
||||
- [Blockstack App](${{ steps.vercel-deployment-blockstack-app.outputs.preview-url }})
|
||||
- [Blockstack Test App](${{ steps.vercel-deployment-blockstack-test-app.outputs.preview-url }})
|
||||
|
||||
Built with commit ${context.sha}.
|
||||
`;
|
||||
if(context.issue.number){
|
||||
if (commentId) {
|
||||
await github.issues.updateComment({
|
||||
...context.repo,
|
||||
comment_id: commentId,
|
||||
body: commentBody,
|
||||
});
|
||||
} else {
|
||||
await github.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: commentBody,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
41
.github/workflows/deploy-docs.yml
vendored
41
.github/workflows/deploy-docs.yml
vendored
@@ -17,7 +17,6 @@ jobs:
|
||||
id: vercel-deployment-preview
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
||||
vercel-org-id: ${{ secrets.ORG_ID }}
|
||||
vercel-project-id: ${{ secrets.PROJECT_ID }}
|
||||
@@ -27,10 +26,48 @@ jobs:
|
||||
id: vercel-deployment-production
|
||||
if: github.event_name == 'push'
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
||||
vercel-org-id: ${{ secrets.ORG_ID }}
|
||||
vercel-project-id: ${{ secrets.PROJECT_ID }}
|
||||
vercel-args: '--prod'
|
||||
scope: ${{ secrets.VERCEL_SCOPE }}
|
||||
working-directory: packages/ui-docs
|
||||
- name: Comment on PR
|
||||
uses: actions/github-script@v2
|
||||
id: comment
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const firstLine = `The Blockstack UI docs have been deployed with Vercel using the code from this PR!`;
|
||||
const { data } = await github.issues.listComments({
|
||||
...context.repo,
|
||||
issue_number: context.issue.number,
|
||||
});
|
||||
const vercelPreviewURLComment = data.find((comment) =>
|
||||
comment.body.includes(firstLine)
|
||||
);
|
||||
const commentId = vercelPreviewURLComment && vercelPreviewURLComment.id || undefined;
|
||||
const commentBody = `
|
||||
#### Blockstack UI Documentation
|
||||
${firstLine}
|
||||
|
||||
- [Blockstack UI Docs](${{ steps.vercel-deployment-preview.outputs.preview-url }})
|
||||
|
||||
Built with commit ${context.sha}.
|
||||
`;
|
||||
if(context.issue.number){
|
||||
if (commentId) {
|
||||
await github.issues.updateComment({
|
||||
...context.repo,
|
||||
comment_id: commentId,
|
||||
body: commentBody,
|
||||
});
|
||||
} else {
|
||||
await github.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: commentBody,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user