Update Hyperliquid Documentation #1391
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: Update Hyperliquid Documentation | |
| on: | |
| schedule: | |
| - cron: '0 */3 * * *' # Every 3 hours | |
| workflow_dispatch: # Manual trigger | |
| permissions: | |
| contents: write | |
| issues: write | |
| jobs: | |
| update-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| ref: main | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Fetch latest documentation | |
| id: fetch-docs | |
| env: | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| GITHUB_REF_NAME: ${{ github.ref_name }} | |
| run: uv run scripts/fetch_docs.py || echo "fetch_failed=true" >> $GITHUB_OUTPUT | |
| continue-on-error: true | |
| - name: Check for changes | |
| id: verify-changed-files | |
| run: git diff --exit-code docs/ || echo "changed=true" >> $GITHUB_OUTPUT | |
| - name: Check for new files | |
| id: verify-new-files | |
| run: | | |
| if [ -n "$(git ls-files --others --exclude-standard docs/)" ]; then | |
| echo "new_files=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate commit message | |
| if: steps.verify-changed-files.outputs.changed == 'true' || steps.verify-new-files.outputs.new_files == 'true' | |
| id: commit-msg | |
| run: | | |
| git add docs/ | |
| CHANGED=$(git diff --name-status --cached | grep "^M" | cut -f2 | grep -E "\.md$" | sed 's|docs/||' | paste -sd ", " -) | |
| ADDED=$(git diff --name-status --cached | grep "^A" | cut -f2 | grep -E "\.md$" | sed 's|docs/||' | paste -sd ", " -) | |
| DELETED=$(git diff --name-status --cached | grep "^D" | cut -f2 | grep -E "\.md$" | sed 's|docs/||' | paste -sd ", " -) | |
| MSG="docs: sync $(date +'%Y-%m-%d')" | |
| [ -n "$CHANGED" ] && MSG="$MSG | updated: $CHANGED" | |
| [ -n "$ADDED" ] && MSG="$MSG | added: $ADDED" | |
| [ -n "$DELETED" ] && MSG="$MSG | removed: $DELETED" | |
| echo "message=$MSG" >> $GITHUB_OUTPUT | |
| - name: Commit and push | |
| if: steps.verify-changed-files.outputs.changed == 'true' || steps.verify-new-files.outputs.new_files == 'true' | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git commit -m "${{ steps.commit-msg.outputs.message }}" | |
| git push | |
| - name: Create issue on failure | |
| if: steps.fetch-docs.outputs.fetch_failed == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const date = new Date().toISOString().split('T')[0]; | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: `Documentation sync failed - ${date}`, | |
| body: `The automated documentation sync failed on ${date}.\n\nCheck the [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) for details.`, | |
| labels: ['bug', 'automation'] | |
| }); |