Skip to content

Commit

Permalink
single file used;
Browse files Browse the repository at this point in the history
  • Loading branch information
Muneeb147 committed Oct 22, 2024
1 parent e4f1d25 commit 931025f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 50 deletions.
36 changes: 9 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,16 @@ on:
- main

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Build Application
run: echo "Building the application"

final_job:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install Dependencies
run: npm install @google-cloud/logging

- name: Final Job
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
run: |
echo "Determining which workflow triggered the Final Job..."
node source/dump-ci-stats-to-gcp-logs.js "Build Job"
- name: Test Application
run: echo "Testing the application"

call_final_job:
needs: test # Ensures this job runs after the 'test' job
uses: ./.github/workflows/dump_ci_stats.yml # Calls the reusable workflow
with:
workflow_name: "Build Job"
31 changes: 31 additions & 0 deletions .github/workflows/dump_ci_stats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Dum GH CI Stats

on:
workflow_call: # This allows the workflow to be reused
inputs:
workflow_name:
description: 'Name of the CI workflow that triggered this job'
required: true
type: string

jobs:
final_job:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install GCP Logging Client
run: npm install @google-cloud/logging

- name: Run Final Job and Send Logs to GCP
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
run: |
node source/dump-ci-stats-to-gcp-logs.js "${{ inputs.workflow_name }}"
28 changes: 5 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,9 @@ jobs:
uses: actions/checkout@v2
- name: Test Application
run: echo "Testing the application"

final_job:
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install Dependencies
run: npm install @google-cloud/logging

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

0 comments on commit 931025f

Please sign in to comment.