-
Notifications
You must be signed in to change notification settings - Fork 1.1k
133 lines (121 loc) 路 5.03 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
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:
aws:
name: Resource Docs
# 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_GH_PAT_DOCS 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@v2
with:
go-version: 1.19.x # TODO(friel) use version_set
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x # TODO(friel) use version_set
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: 3.9.x # TODO(friel) use version_set
- name: Set up DotNet
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 6.0.x # TODO(friel) use version_set
dotnet-quality: ga
- name: Install Pulumi CLI
uses: pulumi/action-install-pulumi-cli@v1.0.1
- name: Check out source code
uses: actions/checkout@v2
with:
path: pulumi
ref: ${{ inputs.ref }}
token: ${{ secrets.PULUMI_BOT_GH_PAT_DOCS }}
- name: Check out pulumi-aws
uses: actions/checkout@v2
with:
repository: pulumi/pulumi-aws
path: pulumi-aws
token: ${{ secrets.PULUMI_BOT_GH_PAT_DOCS }}
- name: Check out pulumi-kubernetes
uses: actions/checkout@v2
with:
repository: pulumi/pulumi-kubernetes
path: pulumi-kubernetes
token: ${{ secrets.PULUMI_BOT_GH_PAT_DOCS }}
- name: Check out docs
uses: actions/checkout@v2
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_GH_PAT_DOCS }}
repository: pulumi/docs
path: docs
- 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"
# 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
pushd 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
popd
./scripts/gen_resource_docs.sh aws true
./scripts/gen_resource_docs.sh kubernetes true
# Undo the changes to the go.mod and go.sum files since we don't want the PR
# to contain local overrides or the PR build in docs repo would fail.
pushd tools/resourcedocsgen
git checkout .
popd
popd
echo "::set-output name=branchName::${BRANCH_NAME}"
echo "::set-output name=prNumber::${PR_NUMBER}"
- 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_GH_PAT_DOCS }}
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 }}