-
Notifications
You must be signed in to change notification settings - Fork 2.2k
93 lines (81 loc) · 3.3 KB
/
callable-docs-update.yml
File metadata and controls
93 lines (81 loc) · 3.3 KB
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
name: Build the API References and open a docs PR
on:
workflow_call:
secrets:
GH_TOKEN_AMPLIFY_JS_WRITE:
required: true
jobs:
docs-update-prep:
name: Prepare for docs update
runs-on: ubuntu-latest
steps:
- name: Generate a temporary branch name for docs update PR
id: generate-branch-name
run: |
echo "BRANCH_NAME=temp/amplify-js-$(date +%s)" >> "$GITHUB_OUTPUT"
outputs:
branch_name: ${{ steps.generate-branch-name.outputs.BRANCH_NAME }}
docs-update:
name: Publish to amplify-js docs updates
runs-on: ubuntu-latest
needs: docs-update-prep
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: amplify-js
# Minimal depth 0 so we can fetch all git tags.
fetch-depth: 0
- name: Checkout docs repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ github.repository_owner }}/docs
path: docs
token: ${{ secrets.GH_TOKEN_AMPLIFY_JS_WRITE }}
- name: Setup node and build the repository
uses: ./amplify-js/.github/actions/node-and-build
- name: Set github commit user
env:
GITHUB_EMAIL: ${{ vars.GH_EMAIL }}
GITHUB_USER: ${{ vars.GH_USER }}
run: |
git config --global user.email $GITHUB_EMAIL
git config --global user.name $GITHUB_USER
- name: Build docs references
working-directory: ./amplify-js
run: |
yarn run docs:references
- name: Prepare docs temp branch
working-directory: ./docs
env:
TEMP_BRANCH_NAME: ${{ needs.docs-update-prep.outputs.branch_name }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_AMPLIFY_JS_WRITE }}
run: |
# First sync pre-prod/main with main using the "theirs" strategy to resolve conflicts
git fetch origin main pre-prod/main
git checkout pre-prod/main
# Use -X theirs to automatically resolve conflicts in favor of main
git merge origin/main --no-edit -X theirs --allow-unrelated-histories
echo "MERGE COMPLETE"
git push origin pre-prod/main
# Now create a new branch from the updated pre-prod/main
git checkout -b $TEMP_BRANCH_NAME
- name: Setup yarn berry and Update API references
working-directory: ./docs
run: |
npm install -g corepack
corepack enable
yarn -v
# Update API references
yarn && yarn clean-references -- -p amplify-js
git add .
git commit --allow-empty -m "chore: Update amplify-js API references"
- name: Create a docs PR to merge api references back into the docs site
working-directory: ./docs
env:
TEMP_BRANCH_NAME: ${{ needs.docs-update-prep.outputs.branch_name }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_AMPLIFY_JS_WRITE }}
run: |
git push origin $TEMP_BRANCH_NAME
# Create PR from the temp branch to pre-prod/main
gh pr create -B pre-prod/main -H $TEMP_BRANCH_NAME --title 'chore: amplify-js api references update' --body 'Merge the api references changes from the most recent release.'