Skip to content

Automated Docs Release PR for TFE v000011-1 #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
140 changes: 79 additions & 61 deletions .github/workflows/copy-cloud-docs-for-tfe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
branch:
description: 'Ex: docs-tfe-releases/v123456-1; ptfe-releases/v123456-1'
description: 'Release branch. (Ex: docs-tfe-releases/v123456-1, ptfe-releases/v123456-1)'
required: true

env:
Expand Down Expand Up @@ -69,51 +69,41 @@ jobs:
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
ref: ${{env.release_branch}}
path: "${{github.workspace}}/release"
path: '${{github.workspace}}/release'

- name: Checkout main for new docs version ACTUAL PR
# MAKE THE RELEASE PR
- name: Checkout main for new docs version RELEASE PR
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
path: "${{github.workspace}}/new-docs-pr"

- name: Checkout main for new docs version DIFF PR
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
path: "${{github.workspace}}/new-docs-diff-pr"
path: '${{github.workspace}}/new-docs-pr'

- name: Generate version-metadata for workflow
working-directory: "${{github.workspace}}/release"
working-directory: '${{github.workspace}}/release'
run: |
npm i
npm run prebuild-only-version-metadata

# MAKING THE DIFF PR
- name: Copy files for new docs version DIFF PR
uses: ./release/.github/actions/copy-cloud-docs-for-tfe
with:
source_path: "${{github.workspace}}/release"
target_path: "${{github.workspace}}/new-docs-diff-pr"
- name: Create the new TFE version folder for RELEASE PR
run: |
version=$(jq -r '.["terraform-enterprise"][] | select(.isLatest == true) | .version' "${{github.workspace}}/release/app/api/versionMetadata.json")
echo "Latest terraform-enterprise version: ${version}"
echo "LATEST_TFE_VERSION=$version" >> $GITHUB_ENV

mkdir -p "${{github.workspace}}/new-docs-pr/content/terraform-enterprise/${{env.SERIES}}-${{env.RELEASE}}"

cp -a "${{github.workspace}}/release/content/terraform-enterprise/${version}/." "${{github.workspace}}/new-docs-pr/content/terraform-enterprise/${{env.SERIES}}-${{env.RELEASE}}"

- name: Open new docs docs version DIFF PR
working-directory: "${{github.workspace}}/new-docs-diff-pr"
- name: Open new docs version RELEASE PR
working-directory: '${{github.workspace}}/new-docs-pr'
env:
branch_name: docs-diff/${{env.SERIES}}-${{env.RELEASE}}
branch_name: docs/${{env.SERIES}}-${{env.RELEASE}}
pr_body: |
# Automated Docs DIFF PR for TFE ${{env.SERIES}}-${{env.RELEASE}}

**❗ DO NOT MERGE THIS PR, IT IS FOR DIFFS ONLY ❗**
# Automated Docs Release PR for TFE ${{env.SERIES}}-${{env.RELEASE}}

**TFE Series**: ${{ env.SERIES }}
**TFE Release**: ${{ env.RELEASE }}

This copies over `cloud-docs` from:
- ${{github.server_url}}/${{github.repository}}/tree/${{env.release_branch}}

This PR was created via:
- ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}

Triggered by creation of branch:
- ${{github.server_url}}/${{github.repository}}/tree/${{env.release_branch}}
...Waiting for the diff PR to be created, before finishing this PR's description...

# secrets.WORKFLOW_TESTING_TOKEN requires permissions read:org, repo, workflow
run: |
Expand All @@ -132,38 +122,41 @@ jobs:
git checkout -b ${{env.branch_name}}
git add .

git commit -m "Automated Docs DIFF PR" --no-verify
git commit -m "Automated Release Docs PR" --no-verify
git push origin HEAD

gh pr create \
--body="${{env.pr_body}}" \
--title="Automated Docs DIFF PR for TFE ${{env.SERIES}}-${{env.RELEASE}}" \
--title="Automated Docs Release PR for TFE ${{env.SERIES}}-${{env.RELEASE}}" \
--draft \
--head ${{env.branch_name}} \
--base main

diff_pr_url=$(gh pr view --json url --jq '.url')
echo "DIFF_PR_URL=${diff_pr_url}" >> $GITHUB_ENV
echo "**Automated DIFF PR URL**: ${diff_pr_url}" >> $GITHUB_STEP_SUMMARY

echo "(Closed DIFF PR at ${diff_pr_url} in order to prevent an accidental merge)" >> $GITHUB_STEP_SUMMARY
gh pr close "${diff_pr_url}"
pr_url=$(gh pr view --json url --jq '.url')
echo "PR_URL=${pr_url}" >> $GITHUB_ENV
echo "**Automated Release PR URL**: ${pr_url}" >> $GITHUB_STEP_SUMMARY

# MAKE THE DIFF PR
- name: Checkout main for new docs version DIFF PR
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
path: '${{github.workspace}}/new-docs-diff-pr'
ref: docs/${{env.SERIES}}-${{env.RELEASE}}

# MAKING THE ACTUAL PR
- name: Copy files for new docs version ACTUAL PR
- name: Copy files for new docs version DIFF PR
uses: ./release/.github/actions/copy-cloud-docs-for-tfe
with:
source_path: "${{github.workspace}}/release"
target_path: "${{github.workspace}}/new-docs-pr"
source_path: '${{github.workspace}}/release'
target_path: '${{github.workspace}}/new-docs-diff-pr'
new_TFE_version: ${{env.SERIES}}-${{env.RELEASE}}

- name: Open new docs version ACTUAL PR
working-directory: "${{github.workspace}}/new-docs-pr"
- name: Open new docs version DIFF PR
working-directory: '${{github.workspace}}/new-docs-diff-pr'
env:
branch_name: docs/${{env.SERIES}}-${{env.RELEASE}}
release_branch_name: docs/${{env.SERIES}}-${{env.RELEASE}}
branch_name: docs-diff/${{env.SERIES}}-${{env.RELEASE}}
pr_body: |
# Automated Docs PR for TFE ${{env.SERIES}}-${{env.RELEASE}}
# Automated Docs Diff PR for TFE ${{env.SERIES}}-${{env.RELEASE}}

**TFE Series**: ${{ env.SERIES }}
**TFE Release**: ${{ env.RELEASE }}
Expand All @@ -177,15 +170,8 @@ jobs:
Triggered by creation of branch:
- ${{github.server_url}}/${{github.repository}}/tree/${{env.release_branch}}

Changes against the current TFE docs:
- ${{ env.DIFF_PR_URL }}

### Reviewers

> **Note**: The `digital-content-events` GH App currently does not have permissions to request PR reviews from teams.

- [ ] @hashicorp/ptfe-review
- [ ] @hashicorp/web-platform
Merges into the new docs release version branch:
- ${{ env.PR_URL }}

# secrets.WORKFLOW_TESTING_TOKEN requires permissions read:org, repo, workflow
run: |
Expand All @@ -204,16 +190,48 @@ jobs:
git checkout -b ${{env.branch_name}}
git add .

git commit -m "Automated Docs PR" --no-verify
git commit -m "Automated Docs Diff PR" --no-verify
git push origin HEAD

gh pr create \
--body="${{env.pr_body}}" \
--title="Automated Docs PR for TFE ${{env.SERIES}}-${{env.RELEASE}}" \
--title="Automated Docs Diff PR for TFE ${{env.SERIES}}-${{env.RELEASE}}" \
--draft \
--head ${{env.branch_name}} \
--base main
--base ${{env.release_branch_name}}

pr_url=$(gh pr view --json url --jq '.url')
echo "PR_URL=${pr_url}" >> $GITHUB_ENV
echo "**Automated ACTUAL PR URL**: ${pr_url}" >> $GITHUB_STEP_SUMMARY
diff_pr_url=$(gh pr view --json url --jq '.url')
echo "DIFF_PR_URL=${diff_pr_url}" >> $GITHUB_ENV
echo "**Automated DIFF PR URL**: ${diff_pr_url}" >> $GITHUB_STEP_SUMMARY

- name: Update RELEASE PR with DIFF PR URL
env:
branch_name: docs/${{env.SERIES}}-${{env.RELEASE}}
pr_body: |
# Automated Docs Release PR for TFE ${{env.SERIES}}-${{env.RELEASE}}

**TFE Series**: ${{ env.SERIES }}
**TFE Release**: ${{ env.RELEASE }}

This PR was created via:
- ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}

Triggered by creation of branch:
- ${{github.server_url}}/${{github.repository}}/tree/${{env.release_branch}}

Changes against the current TFE docs:
- ${{ env.DIFF_PR_URL }}

### Reviewers

> **Note**: The `digital-content-events` GH App currently does not have permissions to request PR reviews from teams.

- [ ] @hashicorp/ptfe-review
- [ ] @hashicorp/web-platform
run: |
echo ${{ secrets.WORKFLOW_TESTING_TOKEN }} | gh auth login --with-token
git config --global user.email "[email protected]"
git config --global user.name "tfe-release-bot"

gh pr edit ${{env.PR_URL}} \
--body="${{env.pr_body}}"
Empty file.
Loading
Loading