formal-spec-updated #14
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: "Formal Spec Listener" | |
| on: | |
| repository_dispatch: | |
| types: [formal-spec-updated] | |
| workflow_dispatch: # Allow manual triggering for testing | |
| jobs: | |
| process-formal-spec: | |
| name: "Process Formal Spec Update" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| spec_updated: "true" | |
| steps: | |
| - name: 📥 Checkout repository | |
| uses: actions/checkout@v4 | |
| # Try to download directly from GitHub API to see artifacts in the formal-spec repo | |
| - name: List available artifacts in formal-spec repo | |
| id: list_artifacts | |
| run: | | |
| echo "Checking for artifacts in formal-spec repo..." | |
| echo "Event payload: ${{ toJSON(github.event.client_payload) }}" | |
| ARTIFACTS=$(curl -s -H "Authorization: token ${{ secrets.LEIOS_TRIGGER_PAT }}" \ | |
| "https://api.github.com/repos/input-output-hk/ouroboros-leios-formal-spec/actions/artifacts") | |
| echo "Available artifacts:" | |
| echo "$ARTIFACTS" | jq '.artifacts[] | {name: .name, id: .id, created_at: .created_at, expired: .expired, workflow_run: .workflow_run.id}' || true | |
| # Find the most recent formal-spec-html artifact ID | |
| ARTIFACT_ID=$(echo "$ARTIFACTS" | jq -r '.artifacts[] | select(.name=="formal-spec-html" and .expired==false) | .id' | head -n 1) | |
| if [ -n "$ARTIFACT_ID" ]; then | |
| echo "Found formal-spec-html artifact with ID: $ARTIFACT_ID" | |
| echo "artifact_id=$ARTIFACT_ID" >> $GITHUB_OUTPUT | |
| else | |
| echo "No valid formal-spec-html artifact found" | |
| fi | |
| - name: 📥 Download formal spec HTML by run ID | |
| id: download_by_run | |
| if: github.event.client_payload.run_id != '' | |
| uses: actions/download-artifact@v4 | |
| continue-on-error: true | |
| with: | |
| name: formal-spec-html | |
| repository: input-output-hk/ouroboros-leios-formal-spec | |
| run-id: ${{ github.event.client_payload.run_id }} | |
| path: formal-spec-html | |
| github-token: ${{ secrets.LEIOS_TRIGGER_PAT }} | |
| - name: 📥 Download formal spec HTML by artifact ID (fallback) | |
| id: download_by_id | |
| if: steps.download_by_run.outcome != 'success' && steps.list_artifacts.outputs.artifact_id != '' | |
| uses: dawidd6/action-download-artifact@v6 | |
| continue-on-error: true | |
| with: | |
| name: formal-spec-html | |
| repo: input-output-hk/ouroboros-leios-formal-spec | |
| workflow: formal-spec.yaml | |
| path: formal-spec-html | |
| github_token: ${{ secrets.LEIOS_TRIGGER_PAT }} | |
| search_artifacts: true | |
| if_no_artifact_found: warn | |
| - name: Check download and create placeholder if needed | |
| run: | | |
| mkdir -p formal-spec-html | |
| # Check if we successfully downloaded files | |
| if [ -n "$(ls -A formal-spec-html 2>/dev/null)" ]; then | |
| echo "Using downloaded formal spec HTML" | |
| echo "Files in formal-spec-html directory:" | |
| ls -la formal-spec-html/ | |
| else | |
| echo "No formal spec HTML available, creating placeholder" | |
| echo "<html><body><h1>Formal Specification</h1><p>Formal specification documentation is being updated. Please check back later.</p></body></html>" > formal-spec-html/index.html | |
| fi | |
| - name: 🚢 Upload formal spec files | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: formal-spec-html | |
| path: formal-spec-html | |
| retention-days: 1 | |
| compression-level: 9 | |
| if-no-files-found: error | |
| - name: Verify artifact upload | |
| run: | | |
| echo "Verifying artifact upload..." | |
| curl -s -H "Authorization: token ${{ secrets.LEIOS_TRIGGER_PAT }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" | \ | |
| jq '.artifacts[] | {name: .name, id: .id, created_at: .created_at, expired: .expired}' |