From 5e32ffe54df3a6643caf5adb36bbf9637a9a9496 Mon Sep 17 00:00:00 2001 From: Kevin Yu <31861128+yqlbu@users.noreply.github.com> Date: Sun, 16 Jul 2023 13:07:10 +0800 Subject: [PATCH] ci/feat(build,pr-build,seed-build): integrate check runs to report build status (#218) * ci(build,pr-build,seed-build): integrate check runs * ci(pr-build): use reusable workflow for conclusion stage * fix: fix syntax * fix: fix syntax * fix: fix syntax * ci(pr-build): wrap instantiate-check-runs in pre-actions workflow * ci(pr-build): refactor seed workflow ref * fix: fix syntax * fix: fix syntax * ci(pr-build): inherit secret from org * trigger build * trigger build * fix: fix stage dependency * ci(seed-build): add build-type input * refactor(build): rework main-build logic * patch(pr-build): specify build-type param * fix: fix syntax * patch(seed-build): use string type for build-type * fix: fix syntax * refactor(daily-build): rework workflow logic * chore: pin build workflow to @main * ci: test potential bug fix * chore: ready to be merged * patch/chore(daily-build): update default check-run-id --------- Co-authored-by: dae-bot[bot] <136105375+dae-bot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 11 +++++++++++ .github/workflows/daily-build.yml | 11 +++++++++++ .github/workflows/pr-build.yml | 16 ++++++++++++++-- .github/workflows/seed-build.yml | 21 ++++++++++++++------- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7c89746..e6a46ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,9 +32,20 @@ jobs: repository: ${{ github.repository }} ref: ${{ github.sha }} fetch-depth: 0 + check-runs: '["build", "main-build-passed"]' secrets: inherit build: uses: daeuniverse/dae/.github/workflows/seed-build.yml@main with: ref: ${{ github.sha }} + build-type: main-build + + post-actions: + if: always() + needs: [build] + uses: daeuniverse/ci-seed-jobs/.github/workflows/dae-post-actions.yml@master + with: + check-run-id: "dae-bot[bot]/main-build-passed" + check-run-conclusion: ${{ needs.build.result }} + secrets: inherit diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index 65b36ab..9820771 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -23,9 +23,20 @@ jobs: repository: ${{ github.repository }} ref: ${{ github.sha }} fetch-depth: 0 + check-runs: '["build", "daily-build-passed"]' secrets: inherit build: uses: daeuniverse/dae/.github/workflows/seed-build.yml@main with: ref: ${{ github.sha }} + build-type: daily-build + + post-actions: + if: always() + needs: [build] + uses: daeuniverse/ci-seed-jobs/.github/workflows/dae-post-actions.yml@master + with: + check-run-id: "dae-bot[bot]/daily-build-passed" + check-run-conclusion: ${{ needs.build.result }} + secrets: inherit diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index e6a0baa..ab56f40 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -32,12 +32,24 @@ jobs: repository: ${{ github.repository }} ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 + check-runs: '["build", "pr-build-passed"]' secrets: inherit build: + needs: [pre-actions] if: ${{ github.event.pull_request.draft == false }} uses: daeuniverse/dae/.github/workflows/seed-build.yml@main with: ref: ${{ github.event.pull_request.head.sha }} - pr_build: true - pr_number: ${{ github.event.pull_request.number }} + pr-number: ${{ github.event.pull_request.number }} + build-type: pr-build + secrets: inherit + + post-actions: + if: always() + needs: [build] + uses: daeuniverse/ci-seed-jobs/.github/workflows/dae-post-actions.yml@master + with: + check-run-id: "dae-bot[bot]/pr-build-passed" + check-run-conclusion: ${{ needs.build.result }} + secrets: inherit diff --git a/.github/workflows/seed-build.yml b/.github/workflows/seed-build.yml index c824329..f551830 100644 --- a/.github/workflows/seed-build.yml +++ b/.github/workflows/seed-build.yml @@ -18,13 +18,12 @@ on: type: string required: true default: ${{ github.ref }} - pr_build: - type: boolean - required: false - default: false - pr_number: + pr-number: type: number required: false + build-type: + type: string + description: "[pr-build,main-build,daily-build,release-build]" jobs: build: @@ -78,9 +77,9 @@ jobs: run: | date=$(git log -1 --format="%cd" --date=short | sed s/-//g) commit=$(echo ${REF} | cut -c1-6) - if [[ "${{ inputs.pr_build }}" == "true" ]]; then + if [[ "${{ inputs.build-type }}" == "pr-build" ]]; then count=$(git rev-list --count origin/main..HEAD) - version="unstable-${date}.pr-${{ inputs.pr_number }}.r${count}.${commit}" + version="unstable-${date}.pr-${{ inputs.pr-number }}.r${count}.${commit}" else count=$(git rev-list --count HEAD) version="unstable-${date}.r${count}.${commit}" @@ -150,3 +149,11 @@ jobs: with: name: dae-${{ steps.get_filename.outputs.ASSET_NAME }}.zip path: build/* + + - name: Report result + uses: daeuniverse/ci-seed-jobs/common/report-check-run@master + if: always() + with: + app_id: ${{ secrets.GH_APP_ID }} + private_key: ${{ secrets.GH_APP_PRIVATE_KEY }} + id: "dae-bot[bot]/build"