-
Notifications
You must be signed in to change notification settings - Fork 55
113 lines (90 loc) · 4.1 KB
/
draft_build.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Sync draft spec with ballerina.io
on:
push:
tags:
- 'v*-*-*'
workflow_dispatch:
jobs:
sync_draft_spec:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}
steps:
- name: Checkout ballerina-spec
uses: actions/checkout@v2
- name: Clone ballerina-dev-website
run: git clone -b gh-pages --single-branch https://ballerina-bot:$GITHUB_TOKEN@github.com/ballerina-platform/ballerina-dev-website.git
- name: Clone ballerina-prod-website
run: git clone -b gh-pages --single-branch https://ballerina-bot:$GITHUB_TOKEN@github.com/ballerina-platform/ballerina-platform.github.io.git
- name: Make new folder location in ballerina-dev-website
run: |
cd ballerina-dev-website/spec/lang/draft
array=($(echo $GITHUB_REF | tr "/" "\n"))
len=${#array[@]}
echo "${array[len-1]}"
if [ -d "${array[len-1]}" ]; then rm -Rf "${array[len-1]}"; fi
mkdir "${array[len-1]}"
echo "NEW_FOLDER=${array[len-1]}" >> $GITHUB_ENV
- name: Make new folder location in ballerina-prod-website
run: |
cd ballerina-platform.github.io/spec/lang/draft
if [ -d "${NEW_FOLDER}" ]; then rm -Rf "${NEW_FOLDER}"; fi
mkdir "${NEW_FOLDER}"
- name: Update the latest to new url in ballerina-dev-website
run: |
cd ballerina-dev-website/spec/lang/draft/latest
echo -e "---\nredirect_to: /spec/lang/draft/$NEW_FOLDER/\n---" > index.md
- name: Update the latest to new url in ballerina-prod-website
run: |
cd ballerina-platform.github.io/spec/lang/draft/latest
echo -e "---\nredirect_to: /spec/lang/draft/$NEW_FOLDER/\n---" > index.md
- name: Install xsltproc
run: sudo apt-get install -y xsltproc
- name: Make
run: |
git checkout $GITHUB_REF -b tmp
cd lang
make all
mv build/spec.html build/index.html
- name: Copy new spec to ballerina-dev-website
run: cp -r lang/build/* ballerina-dev-website/spec/lang/draft/$NEW_FOLDER
- name: Copy new spec to ballerina-prod-website
run: cp -r lang/build/* ballerina-platform.github.io/spec/lang/draft/$NEW_FOLDER
- name: Update the list of draft specs in ballerina-dev-website
run: python3 .github/scripts/append.py ballerina-dev-website/_data/draft_spec.json $NEW_FOLDER
- name: Update the list of draft specs in ballerina-prod-website
run: python3 .github/scripts/append.py ballerina-platform.github.io/_data/draft_spec.json $NEW_FOLDER
- name: Sync ballerina-spec with ballerina-dev-website
run: |
cd ballerina-dev-website
git pull origin gh-pages
git config --global user.email "ballerina-bot@ballerina.org"
git config --global user.name "ballerina-bot"
git add _data/draft_spec.json
git add spec/lang/draft/
git commit --allow-empty -m "[Automated] Sync new spec-tag with ballerina dev site"
- name: Sync ballerina-spec with ballerina-prod-website
run: |
cd ballerina-platform.github.io
git pull origin gh-pages
git config --global user.email "ballerina-bot@ballerina.org"
git config --global user.name "ballerina-bot"
git add _data/draft_spec.json
git add spec/lang/draft/
git commit --allow-empty -m "[Automated] Sync new spec-tag with ballerina prod site"
- name: Push new changes to ballerina-dev-website
shell: bash
run: |
cd ballerina-dev-website
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub push
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}
- name: Push new changes to ballerina-prod-website
shell: bash
run: |
cd ballerina-platform.github.io
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub push
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}