Skip to content

Commit b723023

Browse files
committed
ci(pr-build): use local pre/post actions wrappers with GH app secrets
1 parent 9600267 commit b723023

File tree

3 files changed

+144
-3
lines changed

3 files changed

+144
-3
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Post-Build Actions (Local)
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
check-run-id:
8+
type: string
9+
description: "name of the check run"
10+
required: true
11+
check-run-conclusion:
12+
type: string
13+
description: "workflow run status (success|failure|skipped|aborted)"
14+
required: true
15+
16+
jobs:
17+
report-workflow-run:
18+
if: ${{ startsWith(github.event.pull_request.head.repo.full_name, github.repository_owner) && inputs.check-run-conclusion != 'skipped' }}
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@master
22+
with:
23+
repository: daeuniverse/ci-seed-jobs
24+
ref: master
25+
26+
- name: Report workflow run status
27+
uses: ./common/report-workflow-run
28+
with:
29+
app_id: ${{ secrets.GH_APP_ID }}
30+
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
31+
id: ${{ inputs.check-run-id }}
32+
conclusion: ${{ inputs.check-run-conclusion }}

.github/workflows/pr-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
jobs:
2828
pre-actions:
2929
if: ${{ github.event.pull_request.draft == false }}
30-
uses: daeuniverse/ci-seed-jobs/.github/workflows/pre-actions.yml@master
30+
uses: ./.github/workflows/pre-actions.local.yml
3131
with:
3232
repository: ${{ github.repository }}
3333
ref: ${{ github.event.pull_request.head.sha }}
@@ -38,7 +38,7 @@ jobs:
3838
build:
3939
needs: [pre-actions]
4040
if: ${{ github.event.pull_request.draft == false }}
41-
uses: daeuniverse/dae/.github/workflows/seed-build.yml@main
41+
uses: ./.github/workflows/seed-build.yml
4242
with:
4343
ref: ${{ github.event.pull_request.head.sha }}
4444
pr-number: ${{ github.event.pull_request.number }}
@@ -48,7 +48,7 @@ jobs:
4848
post-actions:
4949
if: always()
5050
needs: [build]
51-
uses: daeuniverse/ci-seed-jobs/.github/workflows/dae-post-actions.yml@master
51+
uses: ./.github/workflows/dae-post-actions.local.yml
5252
with:
5353
check-run-id: "dae-bot[bot]/pr-build-passed"
5454
check-run-conclusion: ${{ needs.build.result }}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
name: Pre-Build Actions (Local)
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
repository:
8+
required: true
9+
type: string
10+
ref:
11+
required: true
12+
type: string
13+
fetch-depth:
14+
required: false
15+
default: 0
16+
type: string
17+
check-runs:
18+
type: string
19+
required: false
20+
default: "[]"
21+
notify:
22+
type: boolean
23+
default: false
24+
outputs:
25+
git_sha_long:
26+
description: "git sha (long)"
27+
value: ${{ jobs.export-metadata.outputs.git_sha_long }}
28+
git_sha_short:
29+
description: "git sha (short)"
30+
value: ${{ jobs.export-metadata.outputs.git_sha_short }}
31+
git_commit_msg:
32+
description: "git commit message"
33+
value: ${{ jobs.export-metadata.outputs.git_commit_msg }}
34+
35+
jobs:
36+
set-vars:
37+
runs-on: ubuntu-latest
38+
outputs:
39+
check-runs-matrix: ${{ steps.set-check-runs-matrix.outputs.check-runs-matrix }}
40+
steps:
41+
- name: Set check-runs matrix
42+
id: set-check-runs-matrix
43+
run: |
44+
echo "check-runs-matrix=$input" >> $GITHUB_OUTPUT
45+
env:
46+
input: ${{ inputs.check-runs }}
47+
48+
export-github-context:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Dump GitHub context
52+
env:
53+
GITHUB_CONTEXT: ${{ toJson(github) }}
54+
run: |
55+
echo "$GITHUB_CONTEXT"
56+
57+
export-metadata:
58+
runs-on: ubuntu-latest
59+
outputs:
60+
git_sha_long: ${{ steps.export.outputs.git_sha_long }}
61+
git_sha_short: ${{ steps.export.outputs.git_sha_short }}
62+
git_commit_msg: ${{ steps.export.outputs.git_commit_msg }}
63+
steps:
64+
- uses: actions/checkout@master
65+
with:
66+
repository: ${{ inputs.repository }}
67+
fetch-depth: ${{ inputs.fetch-depth }}
68+
ref: ${{ inputs.ref }}
69+
- name: Get metadata from HEAD
70+
id: export
71+
run: |
72+
echo "git_sha_long=${{ inputs.ref }}" >> $GITHUB_OUTPUT
73+
echo "git_sha_short=$(echo ${{ inputs.ref }} | cut -c1-6)" >> $GITHUB_OUTPUT
74+
echo "git_commit_msg=$(git log --format=%s -n 1 ${{ inputs.ref }})" >> $GITHUB_OUTPUT
75+
76+
notify-build-start:
77+
if: startsWith(github.event.pull_request.head.repo.full_name, github.repository_owner) && inputs.notify
78+
runs-on: ubuntu-latest
79+
needs: [export-github-context, export-metadata]
80+
steps:
81+
- uses: actions/checkout@master
82+
with:
83+
repository: daeuniverse/ci-seed-jobs
84+
ref: master
85+
- id: send-notification
86+
uses: ./notification/notify-build-start
87+
with:
88+
telegram_to: ${{ secrets.TELEGRAM_TO }}
89+
telegram_token: ${{ secrets.TELEGRAM_TOKEN }}
90+
git_sha_long: ${{ needs.export-metadata.outputs.git_sha_long }}
91+
git_sha_short: ${{ needs.export-metadata.outputs.git_sha_short }}
92+
git_commit_msg: ${{ needs.export-metadata.outputs.git_commit_msg }}
93+
94+
instantiate-check-runs:
95+
needs: [set-vars]
96+
if: startsWith(github.event.pull_request.head.repo.full_name, github.repository_owner)
97+
runs-on: ubuntu-latest
98+
strategy:
99+
fail-fast: false
100+
matrix:
101+
id: ${{ fromJson(needs.set-vars.outputs.check-runs-matrix) }}
102+
steps:
103+
- name: Instantiate required check runs
104+
if: ${{ inputs.check-runs != '[]' }}
105+
uses: daeuniverse/ci-seed-jobs/common/instantiate-check-runs@master
106+
with:
107+
app_id: ${{ secrets.GH_APP_ID }}
108+
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
109+
id: "dae-bot[bot]/${{ matrix.id }}"

0 commit comments

Comments
 (0)