Skip to content

Commit 931025f

Browse files
committedOct 22, 2024
single file used;
1 parent e4f1d25 commit 931025f

File tree

3 files changed

+45
-50
lines changed

3 files changed

+45
-50
lines changed
 

‎.github/workflows/build.yml

+9-27
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,16 @@ on:
99
- main
1010

1111
jobs:
12-
build:
12+
test:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout Code
1616
uses: actions/checkout@v2
17-
- name: Build Application
18-
run: echo "Building the application"
19-
20-
final_job:
21-
runs-on: ubuntu-latest
22-
needs:
23-
- build
24-
steps:
25-
- name: Checkout Code
26-
uses: actions/checkout@v2
27-
28-
- name: Setup Node.js
29-
uses: actions/setup-node@v3
30-
with:
31-
node-version: '18'
32-
33-
- name: Install Dependencies
34-
run: npm install @google-cloud/logging
35-
36-
- name: Final Job
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
40-
run: |
41-
echo "Determining which workflow triggered the Final Job..."
42-
node source/dump-ci-stats-to-gcp-logs.js "Build Job"
17+
- name: Test Application
18+
run: echo "Testing the application"
19+
20+
call_final_job:
21+
needs: test # Ensures this job runs after the 'test' job
22+
uses: ./.github/workflows/dump_ci_stats.yml # Calls the reusable workflow
23+
with:
24+
workflow_name: "Build Job"

‎.github/workflows/dump_ci_stats.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Dum GH CI Stats
2+
3+
on:
4+
workflow_call: # This allows the workflow to be reused
5+
inputs:
6+
workflow_name:
7+
description: 'Name of the CI workflow that triggered this job'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
final_job:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v2
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: '18'
22+
23+
- name: Install GCP Logging Client
24+
run: npm install @google-cloud/logging
25+
26+
- name: Run Final Job and Send Logs to GCP
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
30+
run: |
31+
node source/dump-ci-stats-to-gcp-logs.js "${{ inputs.workflow_name }}"

‎.github/workflows/test.yml

+5-23
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,9 @@ jobs:
1616
uses: actions/checkout@v2
1717
- name: Test Application
1818
run: echo "Testing the application"
19-
20-
final_job:
21-
runs-on: ubuntu-latest
22-
needs:
23-
- test
24-
steps:
25-
- name: Checkout Code
26-
uses: actions/checkout@v2
27-
28-
- name: Setup Node.js
29-
uses: actions/setup-node@v3
30-
with:
31-
node-version: '18'
32-
33-
- name: Install Dependencies
34-
run: npm install @google-cloud/logging
3519

36-
- name: Final Job
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
40-
run: |
41-
echo "Determining which workflow triggered the Final Job..."
42-
node source/dump-ci-stats-to-gcp-logs.js "Test Job"
20+
call_final_job:
21+
needs: test # Ensures this job runs after the 'test' job
22+
uses: ./.github/workflows/dump_ci_stats.yml # Calls the reusable workflow
23+
with:
24+
workflow_name: "Test Job"

0 commit comments

Comments
 (0)