-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (136 loc) · 4.73 KB
/
generate-api-reference.yml
File metadata and controls
145 lines (136 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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'
target-workflow:
type: string
default: 'dispatch-update-external-repo.yml'
secrets:
GIT_CLONE_PAT:
required: false
VACCEL_BOT_PRIVATE_KEY:
required: true
jobs:
generate-reference:
name: Generate API Reference
runs-on: [base-dind-2204-amd64]
permissions:
contents: write
steps:
- name: Checkout .github directory
uses: actions/checkout@v6
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@v2
with:
app-id: ${{ vars.VACCEL_BOT_APP_ID }}
private-key: ${{ secrets.VACCEL_BOT_PRIVATE_KEY }}
owner: ${{ inputs.target-repo-owner }}
repositories: ${{ inputs.target-repo-name }}
permission-actions: write
- name: Trigger docs update
id: trigger-update
uses: the-actions-org/workflow-dispatch@v4
env:
RUN_NAME: >-
Update External Repo ${{ github.repository }}
[Run ID: ${{ github.run_id }}]
with:
workflow: ${{ inputs.target-workflow }}
ref: main
repo: ${{ inputs.target-repo-owner }}/${{ inputs.target-repo-name }}
token: ${{ steps.generate-token.outputs.token }}
run-name: ${{ env.RUN_NAME }}
inputs: >-
{
"run-name": "${{ env.RUN_NAME }}",
"trigger-id": "${{ github.run_id }}",
"ref": "${{ steps.get-rev-info.outputs.sha }}",
"branch": "${{ steps.get-rev-info.outputs.branch }}",
"repo": "${{ github.repository }}",
"deploy": "${{ inputs.deploy }}"
}
display-workflow-run-url-interval: 10s
display-workflow-run-url-timeout: 2m
wait-for-completion-interval: 30s
wait-for-completion-timeout: 20m
workflow-logs: json-output
- name: Print remote request info
run: |
remote_repo="${{ inputs.target-repo-owner }}/${{ inputs.target-repo-name }}"
remote_id="${{ steps.trigger-update.outputs.workflow-id }}"
remote_url="${{ steps.trigger-update.outputs.workflow-url }}"
echo "## Remote request info" >> "$GITHUB_STEP_SUMMARY"
echo "- Triggered **${remote_repo}** run [#${remote_id}](${remote_url})" \
>> "$GITHUB_STEP_SUMMARY"
[[ "${{ inputs.deploy }}" == 'false' ]] && exit 0
logs=$(cat <<'EOF'
${{ steps.trigger-update.outputs.workflow-logs }}
EOF
)
pr_number=$(
echo "$logs" | jq -r '
.["Update Repo / Verify Build"]
| map(select(
.message != null
and (.message | test("Pull request number"))
))
| map(.message | capture("Pull request number: (?<val>[^\\s]+)").val)
| .[1]
'
)
pr_operation=$(
echo "$logs" | jq -r '
.["Update Repo / Verify Build"]
| map(select(
.message != null
and (.message | test("Pull request operation"))
))
| map(.message | capture("Pull request operation: (?<val>[^\\s]+)").val)
| .[1]
'
)
pr_url=$(
echo "$logs" | jq -r '
.["Update Repo / Verify Build"]
| map(select(
.message != null
and (.message | test("Pull request URL"))
))
| map(.message | capture("Pull request URL: (?<val>[^\\s]+)").val)
| .[1]
'
)
echo ""
echo "${pr_operation^} PR: ${pr_url}"
echo "- ${pr_operation^} PR [${remote_repo}#${pr_number}](${pr_url})" \
>> "$GITHUB_STEP_SUMMARY"