diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 594b0aa..517d161 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,10 +9,28 @@ on: - main jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - name: Run Build - run: echo "Building the project" + build: + 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: '16' + + - name: Final Job + run: | + echo "Determining which workflow triggered the Final Job..." + node source/dump-ci-stats-to-gcp-logs.js "Build Job" \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index a587381..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Deploy Job - -on: - push: - branches: - - main - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - name: Deploy Application - run: echo "Deploying the application" diff --git a/.github/workflows/final_check.yml b/.github/workflows/final_check.yml deleted file mode 100644 index 726039b..0000000 --- a/.github/workflows/final_check.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Final Job - -on: - workflow_run: - workflows: - - Build Job - - Test Job - - Deploy Job - - Security Check # Add this line if you have a 4th workflow - types: - - completed - -jobs: - final_check: - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - name: Final Job - run: echo "All workflows are completed. Performing final actions." diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4dae083..b6f7068 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,10 +9,28 @@ on: - main jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - name: Run Tests - run: echo "Running tests" + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Test Application + run: echo "Testing 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: '16' + + - name: Final Job + run: | + echo "Determining which workflow triggered the Final Job..." + node source/dump-ci-stats-to-gcp-logs.js "Test Job" \ No newline at end of file diff --git a/source/dump-ci-stats-to-gcp-logs.js b/source/dump-ci-stats-to-gcp-logs.js new file mode 100644 index 0000000..79f0528 --- /dev/null +++ b/source/dump-ci-stats-to-gcp-logs.js @@ -0,0 +1,11 @@ +// Access the command line arguments passed to the script +const inputParam = process.argv[2]; // process.argv[0] is 'node', argv[1] is the script path + +// Check if an argument was provided +if (!inputParam) { + console.error("No parameter provided! Please pass a parameter as an argument."); + process.exit(1); // Exit with a non-zero code to indicate an error +} + +// Log the provided parameter to the console +console.log(`The provided parameter is: ${inputParam}`); \ No newline at end of file