Skip to content

ci: Update workflows #3

ci: Update workflows

ci: Update workflows #3

name: Generate API Reference
on:
workflow_call:
inputs:
actions-repo:
type: string
default: 'nubificus/vaccel'
actions-rev:
type: string
default: 'main'
deploy:
type: boolean
default: false
target-repo-owner:
type: string
default: 'nubificus'
target-repo-name:
type: string
default: 'vaccel-docs_test'
target-workflow:
type: string
default: 'dispatch-update-external-repo.yml'
default: 'dispatch-update-external-repo.yml'
secrets:
GIT_CLONE_PAT:
required: false
jobs:
generate-reference:
name: Generate API Reference
runs-on: [base-dind-2204-amd64]
permissions:
contents: write
steps:
- name: Checkout .github directory
uses: actions/checkout@v4
with:
sparse-checkout: .github
repository: ${{ inputs.actions-repo }}
ref: ${{ inputs.actions-rev }}
- name: Initialize workspace
uses: ./.github/actions/initialize-workspace
with:
submodules: 'false'
remote-actions-repo: ${{ inputs.actions-repo }}
token: ${{ secrets.GIT_CLONE_PAT || github.token }}
fetch-depth: 0
- name: Determine SHA and branch
id: get-rev-info
uses: ./.github/actions/get-revision-info
- name: Generate vaccel-bot token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.VACCEL_BOT_APP_ID }}
private-key: ${{ secrets.VACCEL_BOT_PRIVATE_KEY }}
- name: Generate request metadata
id: generate-meta
run: |
id="${{ github.repository }}-$(date +%s)"
echo "trigger-id=${id}" | tee -a "$GITHUB_OUTPUT"
json_metadata=$(jq -nc \
--arg id '${{ steps.generate-meta.outputs.trigger-id }}' \
--arg rev '${{ steps.get-rev-info.outputs.branch }}' \
--arg repo '${{ github.repository }}' \
--arg deploy '${{ inputs.deploy }}' \
'{"trigger-id": $id, rev: $rev, repo: $repo, deploy: $deploy}')
echo "trigger-meta=${json_metadata}" | tee -a "$GITHUB_OUTPUT"
# - name: Trigger docs update
# id: trigger-update
# uses: codex-/return-dispatch@v2
# with:
# token: ${{ steps.generate-token.outputs.token }}
# ref: ci_add_python_api_reference
# owner: ${{ inputs.target-repo-owner }}
# repo: ${{ inputs.target-repo-name }}
# workflow: ${{ inputs.target-workflow }}
# workflow_inputs: ${{ steps.generate-meta.outputs.trigger-meta }}
# workflow_timeout_seconds: 10 # Default: 300
# distinct_id: ${{ steps.generate-meta.outputs.trigger-id }}
#
# - name: Wait for remote workflow result
# uses: codex-/await-remote-run@v1
# with:
# token: ${{ steps.generate-token.outputs.token }}
# owner: ${{ inputs.target-repo-owner }}
# repo: ${{ inputs.target-repo-name }}
# run_id: ${{ steps.trigger-update.outputs.run_id }}
# - name: Trigger docs update
# id: trigger-update
# uses: nick-fields/retry@v3
# with:
# timeout_seconds: 5
# max_attempts: 6
# command: |
# id="${{ github.repository }}-$(date +%s)"
# curl -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \
# https://api.github.com/repos/${{ inputs.target-repo-owner }}/${{ inputs.target-repo-name }}/dispatches \
# -d '{
# "event_type": "update-external-repo",
# "client_payload": {
# "id": "${id)"
# "rev": "${{ steps.get-rev-info.outputs.branch }}",
# "repo": "${{ github.repository }}",
# "deploy": "${{ inputs.deploy }}"
# }
# }'
# echo "trigger-id=${id}" | tee -a "$GITHUB_OUTPUT"
- name: Trigger docs update
id: trigger-update
run: |
id="${{ github.repository }}-$(date +%s)"
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \
https://api.github.com/repos/${{ inputs.target-repo-owner }}/${{ inputs.target-repo-name }}/dispatches \
-d '{
"event_type": "update-external-repo",
"client_payload": {
"id": "${id)"
"rev": "${{ steps.get-rev-info.outputs.branch }}",
"repo": "${{ github.repository }}",
"deploy": "${{ inputs.deploy }}"
}
}'
echo "trigger-id=${id}" | tee -a "$GITHUB_OUTPUT"
#
# - name: Get remote workflow ID
# id: get-remote-id
# uses: nick-fields/retry@v3
# with:
# timeout_seconds: 5
# max_attempts: 6
# command: |
# run_json=$(curl -s \
# -H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \
# "https://api.github.com/repos/nubificus/vaccel-docs/actions/runs?event=repository_dispatch")
# run_id=$(echo "$run_json" | \
# jq -r --arg tid "${{ steps.gen.outputs.trigger-id }}" '.workflow_runs[] | select(.run_name | contains($tid) | .id' | \
# head -n 1)
# if [ -z "$run_id" ] || [ "$run_id" = "null" ]; then
# echo "Remote run ID not available. Retrying."
# exit 1
# else
# echo "Got remote ID"
# echo "remote-id=${run_id}" | tee -a "$GITHUB_OUTPUT"
# break
# fi
#
# - name: Wait for remote workflow result
# uses: codex-/await-remote-run@v1
# with:
# token: ${{ steps.generate-token.outputs.token }}
# owner: nubificus
# repo: vaccel-docs
# run_id: ${{ steps.get-remote-id.outputs.remote-id }}