68 lines (54 loc) · 2.44 KB
/
update_api_docs.yml
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
name: Create PR for new API Docs pages
on:
push:
branches:
- master
paths:
- '_data/stable-latest/**'
jobs:
apidoc-gen:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.WEBSITE_TOKEN }}
steps:
- name: Install jq for json manipulation
run: sudo apt-get install jq
- name: Checkout code
uses: actions/checkout@v2
- name: Clone ballerina-release repo
run: git clone https://github.com/ballerina-platform/ballerina-release
- name: Get API Docs from dist-dev
run: |
VERSION="`jq -r '.version' _data/stable-latest/metadata.json`"
echo "curl http://dist-dev.ballerina.io/downloads/$VERSION/ballerina-$VERSION.zip --output ballerina.zip"
curl http://dist-dev.ballerina.io/downloads/$VERSION/ballerina-$VERSION.zip --output ballerina.zip
unzip ballerina.zip
- name: Add redirects (we can remove this for 2.0)
run: |
VERSION="`jq -r '.version' _data/stable-latest/metadata.json`"
mv ./ballerina-$VERSION/distributions/jballerina-$VERSION/docs ./ballerina-release/apiDocRedirectionModifier/
cd ballerina-release/apiDocRedirectionModifier
./redirection.sh ./docs v1-2 1.2/learn/api-docs/ballerina/ target
- name: Remove old API Docs
run: git rm -r 1.2/learn/api-docs/ballerina
- name: Copy newly generated API Docs
run: |
VERSION="`jq -r '.version' _data/stable-latest/metadata.json`"
cp -r ballerina-release/apiDocRedirectionModifier/target 1.2/learn/api-docs/ballerina
- name: Push changes for new API Docs
run: |
git checkout automate-apidoc-$GITHUB_SHA 2>/dev/null || git checkout -b automate-apidoc-$GITHUB_SHA
git pull origin master
git config --global user.email "ballerina-bot@ballerina.org"
git config --global user.name "ballerina-bot"
git add 1.2/learn/api-docs/ballerina
git commit --allow-empty -m 'Update API Docs'
git push --set-upstream origin automate-apidoc-$GITHUB_SHA
echo 'Successfully pushed to automate-apidoc-$GITHUB_SHA branch'
- name: Create pull request for new Release-notes/Archive pages
shell: bash
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub pull-request -m '[Automated] Update API Docs pages for the new release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}