-
Notifications
You must be signed in to change notification settings - Fork 1.1k
171 lines (152 loc) 路 5.96 KB
/
ci-test-docs-generation.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Test Docs Generation
on:
workflow_call:
inputs:
ref:
required: true
description: "GitHub ref to use"
type: string
pull_request_number:
required: true
description: "Pull request number"
type: string
pull_request_author:
required: true
description: "Pull request author, as a login name"
type: string
env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
DOTNET_ROLL_FORWARD: "Major"
permissions:
contents: read
jobs:
matrix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: build matrix
id: matrix
run: |
echo "::group::Version set variable"
VERSION_SET=$(./scripts/get-job-matrix.py \
generate-version-set \
--version-set current
)
echo "::endgroup::"
echo "::group::Version set"
echo "$VERSION_SET" | yq -P '.'
echo "::endgroup::"
echo "::group::Set outputs"
./.github/scripts/set-output version-set "${VERSION_SET}"
echo "::endgroup::"
outputs:
version-set: "${{ fromJson(steps.matrix.outputs.version-set) }}"
aws:
name: Resource Docs
needs: [matrix]
# Verify that the event is not triggered by a fork since forks cannot
# access secrets other than the default GITHUB_TOKEN. Specifically,
# this workflow relies on the secret PULUMI_BOT_TOKEN to create a
# draft PR in the docs repo.
env:
GOPATH: ${{ github.workspace }}
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ fromJson(needs.matrix.outputs.version-set).go }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ fromJson(needs.matrix.outputs.version-set).nodejs }}
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ fromJson(needs.matrix.outputs.version-set).python }}
- name: Set up DotNet
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ fromJson(needs.matrix.outputs.version-set).dotnet }}
dotnet-quality: ga
- name: Install Pulumi CLI
uses: pulumi/action-install-pulumi-cli@v1.0.1
- name: Check out source code
uses: actions/checkout@v4
with:
path: pulumi
ref: ${{ inputs.ref }}
token: ${{ secrets.PULUMI_BOT_TOKEN }}
- name: Check out pulumi-aws
uses: actions/checkout@v4
with:
repository: pulumi/pulumi-aws
path: pulumi-aws
token: ${{ secrets.PULUMI_BOT_TOKEN }}
- name: Check out pulumi-kubernetes
uses: actions/checkout@v4
with:
repository: pulumi/pulumi-kubernetes
path: pulumi-kubernetes
token: ${{ secrets.PULUMI_BOT_TOKEN }}
- name: Check out docs
uses: actions/checkout@v4
with:
# Use the PAT and not the default GITHUB_TOKEN since we want to create a branch
# in this workflow and push it to a remote that is NOT the current repo, i.e. pulumi/pulumi.
token: ${{ secrets.PULUMI_BOT_TOKEN }}
repository: pulumi/docs
path: docs
- name: Check out registry
uses: actions/checkout@v4
with:
repository: pulumi/registry
path: registry
- name: Regenerate resource docs
id: regenerate-resource-docs
run: |
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
BRANCH_NAME="${GITHUB_ACTOR}/${PR_NUMBER}-test-generator-changes"
pushd registry/tools/resourcedocsgen
go mod edit -replace github.com/pulumi/pulumi/pkg/v3=../../../pulumi/pkg
go mod edit -replace github.com/pulumi/pulumi/sdk/v3=../../../pulumi/sdk
go mod tidy
if [ -z "${GOPATH:-}" ]; then
echo "GOPATH is empty. Defaulting to ${HOME}/go"
GOPATH="${HOME}/go"
fi
go build -o "${GOPATH}/bin/resourcedocsgen" .
export PATH="${GOPATH}/bin/":$PATH
popd
# If generating docs for more providers here, be sure to update
# the description of the draft PR that is opened in the next step.
pushd docs
./scripts/gen_resource_docs.sh aws true v5.42.0
./scripts/gen_resource_docs.sh kubernetes true
popd
echo "branchName=${BRANCH_NAME}" >> "${GITHUB_OUTPUT}"
echo "prNumber=${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
- name: Create draft docs PR
uses: peter-evans/create-pull-request@v3
with:
draft: true
# We use a repo:public scoped PAT instead of the implicitly provided GITHUB_TOKEN secret here
# because we want the creation of the docs PR to trigger the `on: pull_request` workflow in the
# docs repo. Using a fork repo to raise the PR would also cause the `on: pull_request` workflow
# to trigger, but currently Pulumify in the docs repo does not run for forks, but we want it to
# generate the preview link.
token: ${{ secrets.PULUMI_BOT_TOKEN }}
path: docs
committer: Pulumi Bot <bot@pulumi.com>
author: Pulumi Bot <bot@pulumi.com>
commit-message: Regenerate resource docs
title: Preview resource docs changes for pulumi/pulumi#${{ steps.regenerate-resource-docs.outputs.prNumber }}
body: |
This PR was auto-generated from pulumi/pulumi#${{ steps.regenerate-resource-docs.outputs.prNumber }}.
By default, this PR contains regenerated docs for AWS and Kubernetes only.
After review, this PR should be manually closed.
# Assign the draft PR to the author of the current PR.
assignees: ${{ inputs.pull_request_author }}
branch: ${{ steps.regenerate-resource-docs.outputs.branchName }}