9
9
description : Which `metabase/metabase` branch triggered this workflow
10
10
required : true
11
11
type : string
12
+ repository_dispatch :
13
+ types : [docs_update]
12
14
13
15
jobs :
14
16
build-and-commit :
15
17
runs-on : ubuntu-latest
18
+ env :
19
+ MAIN_REPO_BRANCH : " ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}"
16
20
steps :
17
21
- uses : actions/checkout@v4
18
22
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/[email protected]
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.
20
41
run : |
21
- echo "Got branch_name: ${{ github.event.inputs.branch_name }}"
42
+ bb script/check_incoming_branchname.clj $MAIN_REPO_BRANCH
22
43
23
- - name : Install dependencies
44
+ - name : Install js dependencies
24
45
run : yarn install --frozen-lockfile --prefer-offline
25
46
26
47
- name : Set up Ruby # uses version from .ruby-version
27
48
uses : ruby/setup-ruby@d5fb7a202fc07872cb44f00ba8e6197b70cb0c55 # v1.179.0
28
49
with :
29
50
bundler-cache : true
30
51
31
- - name : Install dependencies
32
- run : bundle install
52
+ - name : Install ruby dependencies
53
+ run : |
54
+ bundle install
33
55
34
56
- name : Update docs
35
57
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"
38
61
39
- - name : " Lint the markdown"
40
- run : |
41
- yarn lint-markdown
62
+ # - name: "Lint the markdown"
63
+ # run: |
64
+ # yarn lint-markdown
42
65
43
- - name : " Lint the styles"
44
- run : |
45
- yarn lint-styles
66
+ # - name: "Lint the styles"
67
+ # run: |
68
+ # yarn lint-styles
46
69
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
54
73
74
+ # - name: "Validate the links"
75
+ # run: |
76
+ # yarn lint-links
55
77
56
78
- name : Build the Jekyll Site
57
79
env :
@@ -60,55 +82,24 @@ jobs:
60
82
run : |
61
83
# Clear the existing site:
62
84
rm -rf _site
63
- # Run the jekyll server :
85
+ # Build the jekyll site :
64
86
JEKYLL_ENV=development bundle exec jekyll build --baseurl '' --config _config.docs.yml --trace
65
87
66
- - name : Setup Babashka
67
- uses : turtlequeue/[email protected]
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
72
94
73
- - name : " Check all of the links "
95
+ - name : Authenticate Git with GITHUB_TOKEN
74
96
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 "[email protected] "
99
+ git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/metabase/docs.metabase.github.io.git"
79
100
80
101
- name : Create the pull request
81
102
env :
82
103
GH_TOKEN : ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
83
104
run : |
84
- if git diff --quiet ; then
85
- echo "No changes to commit."
86
- else
87
- git config user.email "[email protected] "
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 <[email protected] >" --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