112 lines
4.3 KiB
YAML
112 lines
4.3 KiB
YAML
name: MVS Upload & 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: Prepare environment
|
|
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
|
|
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."
|
|
CHANGED_FILES=$(git diff --name-only HEAD~1 2>/dev/null | grep -E '\.(c|bas)$' | head -1)
|
|
echo "Changed 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 changes 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 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.files.outputs.file != '' }}
|
|
run: |
|
|
echo "=== Debug: Starting upload/submit ==="
|
|
echo "File: ${{ steps.files.outputs.file }}"
|
|
echo "Member: ${{ steps.files.outputs.member }}"
|
|
python3 mvs_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.files.outputs.file != '' }}
|
|
run: |
|
|
echo "=== Waiting for job completion ==="
|
|
python3 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.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.files.outputs.file != '' }}
|
|
run: |
|
|
echo "Build complete! Job output PDF has been archived as a build artifact." |