Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

ci: improve build.yml

himself6564dac7cc1cf0
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c17de016d5..204a0d49a0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -46,6 +46,28 @@ jobs:
})
throw new Error('not allowed')
}
+ - name: 'Create Build check'
+ uses: actions/github-script@v6
+ id: create-check
+ # https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run
+ with:
+ debug: ${{ secrets.ACTIONS_STEP_DEBUG || false }}
+ result-encoding: string
+ script: |
+ const { data: pull_request } = await github.rest.pulls.get({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: context.issue.number,
+ });
+ const { data: check } = await github.rest.checks.create({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ head_sha: pull_request.head.sha,
+ name: "Build on Pull Request",
+ status: "in_progress",
+ details_url: process.env.BUILD_URL
+ });
+ return check.id;
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
@@ -82,6 +104,37 @@ jobs:
- name: Export
run: yarn export
+ - name: Set Failure Check
+ uses: actions/github-script@v6
+ if: ${{ failure() }}
+ with:
+ debug: ${{ secrets.ACTIONS_STEP_DEBUG || false }}
+ result-encoding: string
+ script: |
+ await github.rest.checks.update({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ check_run_id: ${{ steps.create-check.outputs.result }},
+ status: "completed",
+ conclusion: "failure",
+ completed_at: new Date().toISOString(),
+ });
+ - name: Set Success Check
+ uses: actions/github-script@v6
+ if: ${{ success() }}
+ with:
+ debug: ${{ secrets.ACTIONS_STEP_DEBUG || false }}
+ result-encoding: string
+ script: |
+ await github.rest.checks.update({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ check_run_id: ${{ steps.create-check.outputs.result }},
+ status: "completed",
+ conclusion: "success",
+ completed_at: new Date().toISOString(),
+ });
+
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
@@ -230,6 +283,28 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
+ - name: 'Create Unit test check'
+ uses: actions/github-script@v6
+ id: create-check
+ # https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run
+ with:
+ debug: ${{ secrets.ACTIONS_STEP_DEBUG || false }}
+ result-encoding: string
+ script: |
+ const { data: pull_request } = await github.rest.pulls.get({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: context.issue.number,
+ });
+ const { data: check } = await github.rest.checks.create({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ head_sha: pull_request.head.sha,
+ name: "Unit Test",
+ status: "in_progress",
+ details_url: process.env.BUILD_URL
+ });
+ return check.id;
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
@@ -255,6 +330,37 @@ jobs:
- name: Unit Test
run: yarn run test:unit:coverage
+ - name: Set Failure Check
+ uses: actions/github-script@v6
+ if: ${{ failure() }}
+ with:
+ debug: ${{ secrets.ACTIONS_STEP_DEBUG || false }}
+ result-encoding: string
+ script: |
+ await github.rest.checks.update({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ check_run_id: ${{ steps.create-check.outputs.result }},
+ status: "completed",
+ conclusion: "failure",
+ completed_at: new Date().toISOString(),
+ });
+ - name: Set Success Check
+ uses: actions/github-script@v6
+ if: ${{ success() }}
+ with:
+ debug: ${{ secrets.ACTIONS_STEP_DEBUG || false }}
+ result-encoding: string
+ script: |
+ await github.rest.checks.update({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ check_run_id: ${{ steps.create-check.outputs.result }},
+ status: "completed",
+ conclusion: "success",
+ completed_at: new Date().toISOString(),
+ });
+
- name: Upload unit test coverage results
uses: codecov/codecov-action@v3
with: