|
| 1 | +name: Generate API Reference |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + actions-repo: |
| 7 | + type: string |
| 8 | + default: 'nubificus/vaccel' |
| 9 | + actions-rev: |
| 10 | + type: string |
| 11 | + default: 'main' |
| 12 | + deploy: |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + target-repo-owner: |
| 16 | + type: string |
| 17 | + default: 'nubificus' |
| 18 | + target-repo-name: |
| 19 | + type: string |
| 20 | + default: 'vaccel-docs_test' |
| 21 | + target-workflow: |
| 22 | + type: string |
| 23 | + default: 'dispatch-update-external-repo.yml' |
| 24 | + default: 'dispatch-update-external-repo.yml' |
| 25 | + secrets: |
| 26 | + GIT_CLONE_PAT: |
| 27 | + required: false |
| 28 | + |
| 29 | +jobs: |
| 30 | + generate-reference: |
| 31 | + name: Generate API Reference |
| 32 | + runs-on: [base-dind-2204-amd64] |
| 33 | + permissions: |
| 34 | + contents: write |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Checkout .github directory |
| 38 | + uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + sparse-checkout: .github |
| 41 | + repository: ${{ inputs.actions-repo }} |
| 42 | + ref: ${{ inputs.actions-rev }} |
| 43 | + |
| 44 | + - name: Initialize workspace |
| 45 | + uses: ./.github/actions/initialize-workspace |
| 46 | + with: |
| 47 | + submodules: 'false' |
| 48 | + remote-actions-repo: ${{ inputs.actions-repo }} |
| 49 | + token: ${{ secrets.GIT_CLONE_PAT || github.token }} |
| 50 | + fetch-depth: 0 |
| 51 | + |
| 52 | + - name: Determine SHA and branch |
| 53 | + id: get-rev-info |
| 54 | + uses: ./.github/actions/get-revision-info |
| 55 | + |
| 56 | + - name: Generate vaccel-bot token |
| 57 | + id: generate-token |
| 58 | + uses: actions/create-github-app-token@v1 |
| 59 | + with: |
| 60 | + app-id: ${{ vars.VACCEL_BOT_APP_ID }} |
| 61 | + private-key: ${{ secrets.VACCEL_BOT_PRIVATE_KEY }} |
| 62 | + |
| 63 | + - name: Generate request metadata |
| 64 | + id: generate-meta |
| 65 | + run: | |
| 66 | + id="${{ github.repository }}-$(date +%s)" |
| 67 | + echo "trigger-id=${id}" | tee -a "$GITHUB_OUTPUT" |
| 68 | + json_metadata=$(jq -nc \ |
| 69 | + --arg id '${{ steps.generate-meta.outputs.trigger-id }}' \ |
| 70 | + --arg rev '${{ steps.get-rev-info.outputs.branch }}' \ |
| 71 | + --arg repo '${{ github.repository }}' \ |
| 72 | + --arg deploy '${{ inputs.deploy }}' \ |
| 73 | + '{"trigger-id": $id, rev: $rev, repo: $repo, deploy: $deploy}') |
| 74 | + echo "trigger-meta=${json_metadata}" | tee -a "$GITHUB_OUTPUT" |
| 75 | +
|
| 76 | +# - name: Trigger docs update |
| 77 | +# id: trigger-update |
| 78 | +# uses: codex-/return-dispatch@v2 |
| 79 | +# with: |
| 80 | +# token: ${{ steps.generate-token.outputs.token }} |
| 81 | +# ref: ci_add_python_api_reference |
| 82 | +# owner: ${{ inputs.target-repo-owner }} |
| 83 | +# repo: ${{ inputs.target-repo-name }} |
| 84 | +# workflow: ${{ inputs.target-workflow }} |
| 85 | +# workflow_inputs: ${{ steps.generate-meta.outputs.trigger-meta }} |
| 86 | +# workflow_timeout_seconds: 10 # Default: 300 |
| 87 | +# distinct_id: ${{ steps.generate-meta.outputs.trigger-id }} |
| 88 | +# |
| 89 | +# - name: Wait for remote workflow result |
| 90 | +# uses: codex-/await-remote-run@v1 |
| 91 | +# with: |
| 92 | +# token: ${{ steps.generate-token.outputs.token }} |
| 93 | +# owner: ${{ inputs.target-repo-owner }} |
| 94 | +# repo: ${{ inputs.target-repo-name }} |
| 95 | +# run_id: ${{ steps.trigger-update.outputs.run_id }} |
| 96 | + |
| 97 | + - name: Trigger docs update |
| 98 | + id: trigger-update |
| 99 | + uses: nick-fields/retry@v3 |
| 100 | + with: |
| 101 | + timeout_seconds: 5 |
| 102 | + max_attempts: 6 |
| 103 | + command: | |
| 104 | + id="${{ github.repository }}-$(date +%s)" |
| 105 | + curl -X POST \ |
| 106 | + -H "Accept: application/vnd.github+json" \ |
| 107 | + -H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \ |
| 108 | + https://api.github.com/repos/${{ inputs.target-repo-owner }}/${{ inputs.target-repo-name }}/dispatches \ |
| 109 | + -d '{ |
| 110 | + "event_type": "update-external-repo", |
| 111 | + "client_payload": { |
| 112 | + "id": "${id)" |
| 113 | + "rev": "${{ steps.get-rev-info.outputs.branch }}", |
| 114 | + "repo": "${{ github.repository }}", |
| 115 | + "deploy": "${{ inputs.deploy }}" |
| 116 | + } |
| 117 | + }' |
| 118 | + echo "trigger-id=${id}" | tee -a "$GITHUB_OUTPUT" |
| 119 | +# |
| 120 | +# - name: Get remote workflow ID |
| 121 | +# id: get-remote-id |
| 122 | +# uses: nick-fields/retry@v3 |
| 123 | +# with: |
| 124 | +# timeout_seconds: 5 |
| 125 | +# max_attempts: 6 |
| 126 | +# command: | |
| 127 | +# run_json=$(curl -s \ |
| 128 | +# -H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \ |
| 129 | +# "https://api.github.com/repos/nubificus/vaccel-docs/actions/runs?event=repository_dispatch") |
| 130 | +# run_id=$(echo "$run_json" | \ |
| 131 | +# jq -r --arg tid "${{ steps.gen.outputs.trigger-id }}" '.workflow_runs[] | select(.run_name | contains($tid) | .id' | \ |
| 132 | +# head -n 1) |
| 133 | +# if [ -z "$run_id" ] || [ "$run_id" = "null" ]; then |
| 134 | +# echo "Remote run ID not available. Retrying." |
| 135 | +# exit 1 |
| 136 | +# else |
| 137 | +# echo "Got remote ID" |
| 138 | +# echo "remote-id=${run_id}" | tee -a "$GITHUB_OUTPUT" |
| 139 | +# break |
| 140 | +# fi |
| 141 | +# |
| 142 | +# - name: Wait for remote workflow result |
| 143 | +# uses: codex-/await-remote-run@v1 |
| 144 | +# with: |
| 145 | +# token: ${{ steps.generate-token.outputs.token }} |
| 146 | +# owner: nubificus |
| 147 | +# repo: vaccel-docs |
| 148 | +# run_id: ${{ steps.get-remote-id.outputs.remote-id }} |
0 commit comments