tk5-c90-projects/.gitea/workflows/mvs_submit.yaml
2026-02-09 09:10:49 +00:00

138 lines
5.7 KiB
YAML

name: MVS Submit & Execute
on:
push:
branches: [ master ]
paths:
- 'src/**' # Trigger only if src/ (C sources) changes
- 'jcl/**' # Trigger only if jcl/ (JCL for batch jobs) changes
pull_request:
branches: [ master ]
paths:
- 'src/**' # Same for pull requests
- 'jcl/**'
jobs:
upload-and-run:
runs-on: ubuntu-gitea
steps:
- name: Checkout code
uses: actions/checkout@v4
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 ==="
echo "Current dir: $(pwd)"
echo "Files in repo: $(ls -la)"
apt-get update && apt install -y netcat-traditional python3-requests
nc -h
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 ==="
echo "Current dir: $(pwd)"
echo "Files in repo: $(ls -la)"
echo "=== Debug: Checking for parent commit ==="
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
echo "Parent commit exists; running git diff for added/modified/renamed files."
# Use --diff-filter=AMR to get Added, Modified, and Renamed files (exclude Deleted)
CHANGED_FILES=$(git diff --name-only --diff-filter=AMR HEAD~1 2>/dev/null | grep -E '\.(c|bas)$' | head -1)
echo "Added/Modified files from last commit: '${CHANGED_FILES}'"
else
echo "No parent commit; skipping diff."
CHANGED_FILES=""
fi
echo "=== Debug: Git diff check complete ==="
# Fallback to all .c/.bas files if no changes or no previous commit
if [ -z "$CHANGED_FILES" ]; then
echo "=== Debug: No added/modified files found; running fallback find ==="
# Find newest .c/.bas by modification time (sort -nr on %T@ timestamp)
CHANGED_FILES=$(find . -type f \( -name "*.c" -o -name "*.bas" \) -printf '%T@ %p\n' 2>/dev/null | sort -nr | cut -d' ' -f2- | head -1)
echo "Fallback files (newest first): '${CHANGED_FILES}'"
echo "=== Debug: Fallback complete ==="
fi
if [ -z "$CHANGED_FILES" ]; then
echo "No added/modified C/BAS files found; skipping workflow."
exit 0 # Graceful skip, no failure
fi
echo "=== Debug: Processing final file ==="
echo "Final selected file: '${CHANGED_FILES}'"
echo "file=$CHANGED_FILES" >> $GITHUB_OUTPUT
# Extract member name (handle .c or .bas)
EXT="${CHANGED_FILES##*.}"
BASE=$(basename "$CHANGED_FILES" ".$EXT")
echo "member=$BASE" >> $GITHUB_OUTPUT
echo "=== Debug: File detection complete ==="
- name: Upload to PDS and Submit JCL
if: steps.check.outputs.should_run == 'true' && steps.files.outputs.file != ''
run: |
echo "=== Debug: Starting upload/submit ==="
echo "File: ${{ steps.files.outputs.file }}"
echo "Member: ${{ steps.files.outputs.member }}"
python3 scripts/submit_job.py "${{ steps.files.outputs.file }}" "@05054.SRCLIB.C(${{ steps.files.outputs.member }})"
echo "=== Debug: Upload/submit complete ==="
env:
MVS_BATCH_PASSWORD: ${{ vars.MVS_BATCH_PASSWORD }}
MVS_HOST: "oldcomputernerd.com"
- name: Poll for job completion and retrieve output
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
echo "=== Job output retrieved ==="
env:
MVS_CONSOLE_URL: ${{ vars.MVS_CONSOLE_URL }}
MVS_CONSOLE_USER: ${{ vars.MVS_CONSOLE_USER }}
MVS_CONSOLE_PASSWORD: ${{ secrets.MVS_CONSOLE_PASSWORD }}
LINODE_SSH_HOST: ${{ vars.LINODE_SSH_HOST }}
LINODE_PRINTOUT_DIR: ${{ vars.LINODE_PRINTOUT_DIR }}
LOCAL_PRINTOUT_DIR: /printouts
- name: Upload job output as artifact
if: steps.check.outputs.should_run == 'true' && steps.files.outputs.file != ''
uses: actions/upload-artifact@v3
with:
name: job-output-${{ steps.files.outputs.member }}
path: "${{ steps.files.outputs.member }}_J*.pdf"
if-no-files-found: warn
- name: Report Status
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."
- name: Workflow skipped
if: steps.check.outputs.should_run == 'false'
run: |
echo "Workflow skipped - no added/modified source files in this commit."