name: Downstream Resource Docs Test on: pull_request: paths: - 'pkg/codegen/docs/**' - 'pkg/codegen/docs/docs.go' - 'pkg/codegen/docs/docs_test.go' - '.github/workflows/res-docs-test.yml' 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. if: github.event.pull_request.head.repo.full_name == github.repository env: GOPATH: ${{ github.workspace }} runs-on: ubuntu-latest steps: - name: Install Go uses: actions/setup-go@v1 with: go-version: 1.14.x - name: Add GOBIN to PATH run: | mkdir -p "$(go env GOPATH)/bin" echo "::add-path::$(go env GOPATH)/bin" - name: Install Node.js uses: actions/setup-node@v1 with: node-version: '12.x' - name: Install Pulumi CLI uses: pulumi/action-install-pulumi-cli@releases/v1 - name: Check out source code uses: actions/checkout@master with: path: pulumi - name: Check out pulumi-aws uses: actions/checkout@master with: repository: pulumi/pulumi-aws path: pulumi-aws - name: Check out pulumi-kubernetes uses: actions/checkout@master with: repository: pulumi/pulumi-kubernetes path: pulumi-kubernetes - name: Check out docs uses: actions/checkout@master 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 ./scripts/gen_resource_docs.sh aws true ./scripts/gen_resource_docs.sh kubernetes true 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@v2 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 author: Pulumi Bot 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. # Assign the draft PR to the author of the current PR. assignees: ${{ github.event.pull_request.user.login }} branch: ${{ steps.regenerate-resource-docs.outputs.branchName }} request-to-parent: false