99 description : Which `metabase/metabase` branch triggered this workflow
1010 required : true
1111 type : string
12+ repository_dispatch :
13+ types : [docs_update]
1214
1315jobs :
1416 build-and-commit :
1517 runs-on : ubuntu-latest
18+ env :
19+ MAIN_REPO_BRANCH : " ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}"
1620 steps :
1721 - uses : actions/checkout@v4
1822
19- - name : Display received payload
23+ - name : Set current branch name
24+ run : echo "LOCAL_REPO_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
25+
26+ - name : echo branch name
27+ run : |
28+ echo "Got (metabase) branch_name: $MAIN_REPO_BRANCH"
29+
30+ - name : echo local repo branch
31+ run : |
32+ echo "Running on (docs.metabase.github.io) branch: $LOCAL_REPO_BRANCH"
33+
34+ - name : Setup Babashka
35+ uses : turtlequeue/setup-babashka@v1.7.0
36+ with :
37+ babashka-version : 1.12.199
38+
39+ - name : Filter non-documented branches
40+ description : This will stop the workflow if the branch isn't master or release-x.\d.x.
2041 run : |
21- echo "Got branch_name: ${{ github.event.inputs.branch_name }}"
42+ bb script/check_incoming_branchname.clj $MAIN_REPO_BRANCH
2243
23- - name : Install dependencies
44+ - name : Install js dependencies
2445 run : yarn install --frozen-lockfile --prefer-offline
2546
2647 - name : Set up Ruby # uses version from .ruby-version
2748 uses : ruby/setup-ruby@d5fb7a202fc07872cb44f00ba8e6197b70cb0c55 # v1.179.0
2849 with :
2950 bundler-cache : true
3051
31- - name : Install dependencies
32- run : bundle install
52+ - name : Install ruby dependencies
53+ run : |
54+ bundle install
3355
3456 - name : Update docs
3557 run : |
36- ./script/docs-update
37- ./script/docs master --set-version master
58+ # ./script/docs-update
59+ # ./script/docs master --set-version master
60+ ./script/docs "$MAIN_REPO_BRANCH" --set-version "$MAIN_REPO_BRANCH"
3861
39- - name : " Lint the markdown"
40- run : |
41- yarn lint-markdown
62+ # - name: "Lint the markdown"
63+ # run: |
64+ # yarn lint-markdown
4265
43- - name : " Lint the styles"
44- run : |
45- yarn lint-styles
66+ # - name: "Lint the styles"
67+ # run: |
68+ # yarn lint-styles
4669
47- - name : " Lint the scripts"
48- run : |
49- yarn lint-scripts
50-
51- - name : " Validate the links"
52- run : |
53- yarn lint-links
70+ # - name: "Lint the scripts"
71+ # run: |
72+ # yarn lint-scripts
5473
74+ # - name: "Validate the links"
75+ # run: |
76+ # yarn lint-links
5577
5678 - name : Build the Jekyll Site
5779 env :
@@ -60,55 +82,24 @@ jobs:
6082 run : |
6183 # Clear the existing site:
6284 rm -rf _site
63- # Run the jekyll server :
85+ # Build the jekyll site :
6486 JEKYLL_ENV=development bundle exec jekyll build --baseurl '' --config _config.docs.yml --trace
6587
66- - name : Setup Babashka
67- uses : turtlequeue/setup-babashka@v1.7.0
68- with :
69- babashka-version : 1.12.197
70- - name : Check bb runs
71- run : bb --version
88+ # - name: "Check all of the links"
89+ # run: |
90+ # script/links || true
91+ # echo 'checking reported links...'
92+ # echo "htmlproofer spit out a report of length: $(cat htmlproofer.out | wc -l)"
93+ # bb script/analyze_links.clj --htmlproofer-output htmlproofer.out
7294
73- - name : " Check all of the links "
95+ - name : Authenticate Git with GITHUB_TOKEN
7496 run : |
75- script/links || true
76- echo 'checking reported links...'
77- echo "htmlproofer spit out a report of length: $(cat htmlproofer.out | wc -l)"
78- bb script/analyze_links.clj --htmlproofer-output htmlproofer.out
97+ git config --global user.name "Metabase Docs bot"
98+ git config --global user.email "metabase-bot@metabase.com"
99+ git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/metabase/docs.metabase.github.io.git"
79100
80101 - name : Create the pull request
81102 env :
82103 GH_TOKEN : ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
83104 run : |
84- if git diff --quiet ; then
85- echo "No changes to commit."
86- else
87- git config user.email "metabase-bot@metabase.com"
88- git config user.name "Metabase Docs bot"
89- update_branch="docs-update"
90-
91- # Check out or create the update branch
92- if git ls-remote --exit-code --heads origin "$update_branch" > /dev/null; then
93- git fetch origin "$update_branch"
94- git switch "$update_branch"
95- else
96- git switch --create "$update_branch"
97- fi
98-
99- git add _site
100- git commit --author="Metabase Docs bot <metabase-bot@metabase.com>" --message="Update master and latest docs"
101- git push --force origin "$update_branch"
102-
103- # Check if a PR already exists for this branch
104- existing_pr=$(gh pr list --head "$update_branch" --json number --jq '.[0].number')
105-
106- if [ -z "$existing_pr" ]; then
107- gh pr create \
108- --title "Refresh docs (${{ github.event.inputs.branch_name }})" \
109- --body "" \
110- --head "$update_branch"
111- else
112- echo "PR already exists: #$existing_pr"
113- fi
114- fi
105+ bb script/update_or_create_pr.clj $MAIN_REPO_BRANCH
0 commit comments