Skip to content

formal-spec-updated

formal-spec-updated #8

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
# First try to download previous artifacts to have as fallback
- name: 📥 Download previous formal spec HTML for fallback
id: download_previous
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: formal-spec-html
path: previous-formal-spec-html
- name: Check previous artifacts
id: check_previous
run: |
if [ -d "previous-formal-spec-html" ] && [ -n "$(ls -A previous-formal-spec-html 2>/dev/null)" ]; then
echo "Previous formal spec HTML found, will use as fallback"
echo "has_previous=true" >> $GITHUB_OUTPUT
else
echo "No previous formal spec HTML found"
echo "has_previous=false" >> $GITHUB_OUTPUT
fi
# Try to download directly from GitHub API to see artifacts in the formal-spec repo
- name: List available artifacts in formal-spec repo
run: |
curl -s -H "Authorization: token ${{ secrets.LEIOS_TRIGGER_PAT }}" \
"https://api.github.com/repos/input-output-hk/ouroboros-leios-formal-spec/actions/artifacts" | \
jq '.artifacts[] | {name: .name, id: .id, created_at: .created_at, expired: .expired}' || true
- name: 📥 Download formal spec HTML
id: download_new
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: new-formal-spec-html
github-token: ${{ secrets.LEIOS_TRIGGER_PAT }}
- name: Prepare final formal spec HTML
run: |
mkdir -p formal-spec-html
# Check if we successfully downloaded new files
if [ -d "new-formal-spec-html" ] && [ -n "$(ls -A new-formal-spec-html 2>/dev/null)" ]; then
echo "Using newly downloaded formal spec HTML"
cp -r new-formal-spec-html/* formal-spec-html/
# Otherwise use previous version if available
elif [ "${{ steps.check_previous.outputs.has_previous }}" == "true" ]; then
echo "Download failed, using previous formal spec HTML as fallback"
cp -r previous-formal-spec-html/* formal-spec-html/
# Create placeholder as last resort
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
# Show what we're using
echo "Final formal spec HTML contents:"
ls -la formal-spec-html/
- name: 🚢 Upload formal spec files
uses: actions/upload-artifact@v4
with:
name: formal-spec-html
path: formal-spec-html
retention-days: 1