From af44e561f2e6356ee9bf9a045f5c6ba0492f86a5 Mon Sep 17 00:00:00 2001 From: Gregory Gauthier Date: Mon, 9 Feb 2026 09:10:49 +0000 Subject: [PATCH] handle pipeline workflow toggling --- .gitea/workflows/mvs_delete.yaml | 29 ++++++++++++++++++++++++-- .gitea/workflows/mvs_submit.yaml | 35 +++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/mvs_delete.yaml b/.gitea/workflows/mvs_delete.yaml index 945e78f..b78f718 100644 --- a/.gitea/workflows/mvs_delete.yaml +++ b/.gitea/workflows/mvs_delete.yaml @@ -18,7 +18,26 @@ jobs: with: fetch-depth: 0 # Full history for git diff + - name: Check if workflow should run + id: check + run: | + echo "Checking if there are deleted source files..." + if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then + DELETED_FILES=$(git diff --name-only --diff-filter=D HEAD~1 2>/dev/null | grep -E '\.(c|bas)$' || true) + if [ -z "$DELETED_FILES" ]; then + echo "No deleted source files found. Skipping workflow." + echo "should_run=false" >> $GITHUB_OUTPUT + exit 0 + fi + echo "Found deleted files: $DELETED_FILES" + echo "should_run=true" >> $GITHUB_OUTPUT + else + echo "No parent commit, skipping workflow" + echo "should_run=false" >> $GITHUB_OUTPUT + fi + - name: Prepare environment + if: steps.check.outputs.should_run == 'true' id: setup run: | echo "=== Debug: Starting setup ===" @@ -27,6 +46,7 @@ jobs: echo "=== Debug: Setup complete ===" - name: Find deleted source files (deleted only) + if: steps.check.outputs.should_run == 'true' id: deleted run: | echo "=== Debug: Starting deletion detection ===" @@ -63,7 +83,7 @@ jobs: echo "=== Debug: Deletion detection complete ===" - name: Delete removed members from PDS - if: ${{ steps.deleted.outputs.has_deletions == 'true' }} + if: steps.check.outputs.should_run == 'true' && steps.deleted.outputs.has_deletions == 'true' run: | echo "=== Starting deletion of removed members ===" echo "Deleted members: ${{ steps.deleted.outputs.deleted_members }}" @@ -79,6 +99,11 @@ jobs: MVS_HOST: "oldcomputernerd.com" - name: Report Status - if: ${{ steps.deleted.outputs.has_deletions == 'true' }} + if: steps.check.outputs.should_run == 'true' && steps.deleted.outputs.has_deletions == 'true' run: | echo "Deletion complete! Members removed from mainframe PDS." + + - name: Workflow skipped + if: steps.check.outputs.should_run == 'false' + run: | + echo "Workflow skipped - no deleted source files in this commit." diff --git a/.gitea/workflows/mvs_submit.yaml b/.gitea/workflows/mvs_submit.yaml index 98b2a0b..ea6c110 100644 --- a/.gitea/workflows/mvs_submit.yaml +++ b/.gitea/workflows/mvs_submit.yaml @@ -21,7 +21,26 @@ jobs: with: fetch-depth: 0 # Full history for git diff + - name: Check if workflow should run + id: check + run: | + echo "Checking if there are added/modified source files..." + if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then + CHANGED_FILES=$(git diff --name-only --diff-filter=AM HEAD~1 2>/dev/null | grep -E '\.(c|bas)$' || true) + if [ -z "$CHANGED_FILES" ]; then + echo "No added/modified source files found. Skipping workflow." + echo "should_run=false" >> $GITHUB_OUTPUT + exit 0 + fi + echo "Found changed files: $CHANGED_FILES" + echo "should_run=true" >> $GITHUB_OUTPUT + else + echo "No parent commit, allowing workflow to run" + echo "should_run=true" >> $GITHUB_OUTPUT + fi + - name: Prepare environment + if: steps.check.outputs.should_run == 'true' id: setup run: | echo "=== Debug: Starting setup ===" @@ -32,6 +51,7 @@ jobs: echo "=== Debug: Setup complete ===" - name: Find changed source files (added/modified only) + if: steps.check.outputs.should_run == 'true' id: files run: | echo "=== Debug: Starting file detection ===" @@ -74,7 +94,7 @@ jobs: echo "=== Debug: File detection complete ===" - name: Upload to PDS and Submit JCL - if: ${{ steps.files.outputs.file != '' }} + if: steps.check.outputs.should_run == 'true' && steps.files.outputs.file != '' run: | echo "=== Debug: Starting upload/submit ===" echo "File: ${{ steps.files.outputs.file }}" @@ -86,7 +106,7 @@ jobs: MVS_HOST: "oldcomputernerd.com" - name: Poll for job completion and retrieve output - if: ${{ steps.files.outputs.file != '' }} + if: steps.check.outputs.should_run == 'true' && steps.files.outputs.file != '' run: | echo "=== Waiting for job completion ===" python3 scripts/poll_job.py "${{ steps.files.outputs.member }}" 120 @@ -100,7 +120,7 @@ jobs: LOCAL_PRINTOUT_DIR: /printouts - name: Upload job output as artifact - if: ${{ steps.files.outputs.file != '' }} + if: steps.check.outputs.should_run == 'true' && steps.files.outputs.file != '' uses: actions/upload-artifact@v3 with: name: job-output-${{ steps.files.outputs.member }} @@ -108,6 +128,11 @@ jobs: if-no-files-found: warn - name: Report Status - if: ${{ steps.files.outputs.file != '' }} + if: steps.check.outputs.should_run == 'true' && steps.files.outputs.file != '' run: | - echo "Build complete! Job output PDF has been archived as a build artifact." \ No newline at end of file + echo "Build complete! Job output PDF has been archived as a build artifact." + + - name: Workflow skipped + if: steps.check.outputs.should_run == 'false' + run: | + echo "Workflow skipped - no added/modified source files in this commit." \ No newline at end of file