Skip to content

Commit 5fc159b

Browse files
committed
Sync cloud docs workflow
1 parent f9e13e7 commit 5fc159b

File tree

2 files changed

+120
-2
lines changed

2 files changed

+120
-2
lines changed

.github/workflows/create-tfe-release-notes.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ env:
3434
LAST_RELEASE_TAG: ${{ inputs.last-release-tag }}
3535

3636
jobs:
37-
copy-docs:
38-
uses: ./.github/workflows/copy-cloud-docs-for-tfe.yml
37+
sync-docs:
38+
uses: ./.github/workflows/sync-docs-for-tfe.yml
3939
with:
4040
version: ${{ inputs.version }}
4141
secrets: inherit
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Sync Cloud Docs For TFE
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'The TFE version for the upcoming TFE release, format is either vYYYYMM-# or MAJOR.MINOR.PATCH (without a "v" prefix).'
8+
required: true
9+
type: string
10+
workflow_call:
11+
inputs:
12+
version:
13+
description: 'The TFE version for the upcoming TFE release, format is either vYYYYMM-# or MAJOR.MINOR.PATCH (without a "v" prefix).'
14+
required: true
15+
type: string
16+
outputs:
17+
release_branch_name:
18+
description: 'The name of the branch created for the new TFE version docs.'
19+
value: ${{ jobs.copy-docs.outputs.release_branch_name }}
20+
release_branch_pr_url:
21+
description: 'The URL of the release branch created for the new TFE version docs.'
22+
value: ${{ jobs.copy-docs.outputs.release_branch_pr_url }}
23+
diff_branch_pr_url:
24+
description: 'The URL of the diff branch created for the new TFE version docs.'
25+
value: ${{ jobs.copy-docs.outputs.diff_branch_pr_url }}
26+
27+
jobs:
28+
sync-docs:
29+
name: Sync Cloud Docs
30+
runs-on: ubuntu-latest
31+
outputs:
32+
release_branch_name: ${{ steps.check-docs-pr.outputs.docs_branch_name }}
33+
release_branch_pr_url: ${{ steps.check-docs-pr.outputs.release_branch_pr_url }}
34+
diff_branch_pr_url: ${{ steps.update-diff-branch.outputs.diff_branch_pr_url }}
35+
steps:
36+
- name: Series/Release Summary
37+
run: |
38+
echo "# Summary" >> $GITHUB_STEP_SUMMARY
39+
echo "**Workflow ref**: ${{github.ref_name}}" >> $GITHUB_STEP_SUMMARY
40+
echo "" >> $GITHUB_STEP_SUMMARY
41+
echo "Triggered by branch creation (or manual workflow):" >> $GITHUB_STEP_SUMMARY
42+
echo "" >> $GITHUB_STEP_SUMMARY
43+
echo "" >> $GITHUB_STEP_SUMMARY
44+
echo "---" >> $GITHUB_STEP_SUMMARY
45+
46+
- name: Checkout main for new docs version
47+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
48+
with:
49+
path: '${{github.workspace}}/new-docs'
50+
51+
- name: Check if new TFE version docs branch already exist
52+
id: check-docs-pr
53+
working-directory: '${{github.workspace}}/new-docs'
54+
env:
55+
docs_branch_name: tfe-release/${{inputs.version}}
56+
diff_branch_name: HCPTF-diff/${{inputs.version}}
57+
run: |
58+
echo ${{ secrets.TFE_GITHUB_TOKEN }} | gh auth login --with-token
59+
git config --global user.email "team-rel-eng@hashicorp.com"
60+
git config --global user.name "tfe-release-bot"
61+
62+
if [ "$(git ls-remote --heads origin ${{env.docs_branch_name}})" == "" ]; then
63+
echo "❌ branch name ${{env.docs_branch_name}} does not exists, please run copy cloud docs for tfe workflow first to create the branch."
64+
65+
echo "❌ branch name ${{env.docs_branch_name}} does not exists, please run copy cloud docs for tfe workflow first to create the branch." >> $GITHUB_STEP_SUMMARY
66+
67+
exit 1
68+
fi
69+
70+
if [ "$(git ls-remote --heads origin ${{env.diff_branch_name}})" == "" ]; then
71+
echo "❌ branch name ${{env.diff_branch_name}} does not exists, please run copy cloud docs for tfe workflow first to create the branch."
72+
73+
echo "❌ branch name ${{env.diff_branch_name}} does not exists, please run copy cloud docs for tfe workflow first to create the branch." >> $GITHUB_STEP_SUMMARY
74+
75+
exit 1
76+
fi
77+
78+
echo "docs_branch_name=${{env.docs_branch_name}}" >> $GITHUB_OUTPUT
79+
docs_pr_url=$(gh pr view ${{env.docs_branch_name}} --json url --jq '.url')
80+
echo "release_branch_pr_url=${docs_pr_url}" >> $GITHUB_OUTPUT
81+
echo "**TFE Release PR URL**: ${docs_pr_url}" >> $GITHUB_STEP_SUMMARY
82+
83+
- name: Generate version-metadata for workflow
84+
working-directory: '${{github.workspace}}/new-docs'
85+
run: |
86+
npm i
87+
npm run prebuild -- --only-build-version-metadata
88+
89+
- name: Checkout HCPTF-diff for new docs version DIFF PR
90+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
91+
with:
92+
path: '${{github.workspace}}/new-docs-diff-pr'
93+
ref: 'HCPTF-diff/${{inputs.version}}'
94+
95+
- name: Copy files for new docs version DIFF PR
96+
uses: ./new-docs/.github/actions/copy-cloud-docs-for-tfe
97+
with:
98+
source_path: '${{github.workspace}}/new-docs'
99+
target_path: '${{github.workspace}}/new-docs-diff-pr'
100+
new_TFE_version: ${{inputs.version}}
101+
102+
- name: Update existing docs version DIFF branch
103+
id: update-diff-branch
104+
working-directory: '${{github.workspace}}/new-docs-diff-pr'
105+
env:
106+
diff_branch_name: HCPTF-diff/${{inputs.version}}
107+
run: |
108+
echo ${{ secrets.TFE_GITHUB_TOKEN }} | gh auth login --with-token
109+
git config --global user.email "team-rel-eng@hashicorp.com"
110+
git config --global user.name "tfe-release-bot"
111+
112+
git add .
113+
git commit -m "HCP TF changes for TFE release" --no-verify
114+
git push origin HEAD
115+
116+
diff_pr_url=$(gh pr view --json url --jq '.url')
117+
echo "diff_branch_pr_url=${diff_pr_url}" >> $GITHUB_OUTPUT
118+
echo "**Updated DIFF branch**: ${{env.diff_branch_name}}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)