Update Stamp-Implementation.md #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run Stamp Metadata Validation | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| paths: | |
| description: "Files or glob patterns to validate" | |
| required: false | |
| default: "**/*.md" | |
| mode: | |
| description: "Validation mode (check or fix)" | |
| type: choice | |
| options: | |
| - check | |
| - fix | |
| default: "check" | |
| output_dir: | |
| description: "Optional directory to write normalized files" | |
| required: false | |
| jobs: | |
| stamp: | |
| name: Stamp Metadata Validation | |
| runs-on: ubuntu-latest | |
| steps: | |
| # --------------------------------------------------------------- | |
| # CHECKOUT REPO | |
| # --------------------------------------------------------------- | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # --------------------------------------------------------------- | |
| # PYTHON SETUP | |
| # --------------------------------------------------------------- | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| # --------------------------------------------------------------- | |
| # INSTALL STAMP FROM THE REPO | |
| # --------------------------------------------------------------- | |
| - name: Install Stamp | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| # --------------------------------------------------------------- | |
| # DETERMINE MODE + PATHS | |
| # --------------------------------------------------------------- | |
| - name: Configure Execution Parameters | |
| id: config | |
| run: | | |
| MODE="--check" | |
| PATHS="**/*.md" | |
| OUTDIR="" | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| if [[ "${{ inputs.mode }}" == "fix" ]]; then | |
| MODE="--fix" | |
| fi | |
| if [[ -n "${{ inputs.paths }}" ]]; then | |
| PATHS="${{ inputs.paths }}" | |
| fi | |
| if [[ -n "${{ inputs.output_dir }}" ]]; then | |
| OUTDIR="--output-dir ${{ inputs.output_dir }}" | |
| fi | |
| fi | |
| echo "MODE=$MODE" >> $GITHUB_OUTPUT | |
| echo "PATHS=$PATHS" >> $GITHUB_OUTPUT | |
| echo "OUTDIR=$OUTDIR" >> $GITHUB_OUTPUT | |
| # --------------------------------------------------------------- | |
| # RUN STAMP VALIDATION | |
| # --------------------------------------------------------------- | |
| - name: Run Stamp | |
| id: stamp_run | |
| continue-on-error: true | |
| run: | | |
| stamp ${{ steps.config.outputs.MODE }} \ | |
| ${{ steps.config.outputs.OUTDIR }} \ | |
| "${{ steps.config.outputs.PATHS }}" \ | |
| --json > stamp_report.json | |
| echo "EXIT_CODE=$?" >> $GITHUB_OUTPUT | |
| # --------------------------------------------------------------- | |
| # UPLOAD REPORT AS ARTIFACT | |
| # --------------------------------------------------------------- | |
| - name: Upload Validation Report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: stamp-validation-report | |
| path: stamp_report.json | |
| # --------------------------------------------------------------- | |
| # PROCESS STATUS + FAIL PIPELINE IF NEEDED | |
| # --------------------------------------------------------------- | |
| - name: Process Results | |
| if: always() | |
| run: | | |
| CODE=${{ steps.stamp_run.outputs.EXIT_CODE }} | |
| if [[ "$CODE" == "0" ]]; then | |
| echo "✅ Metadata validation passed." | |
| exit 0 | |
| elif [[ "$CODE" == "1" ]]; then | |
| echo "⚠️ Repairable metadata issues detected." | |
| echo "Run workflow_dispatch in 'fix' mode to auto-correct." | |
| exit 1 | |
| elif [[ "$CODE" == "2" ]]; then | |
| echo "❌ FATAL: Noncompliant metadata detected." | |
| echo "Check stamp_report.json for error details." | |
| exit 2 | |
| else | |
| echo "❓ Unknown error occurred." | |
| exit 1 | |
| fi |