-
Notifications
You must be signed in to change notification settings - Fork 42
78 lines (59 loc) · 2.46 KB
/
sw_update_ballerina_by_example.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
name: Create PR for new Swan Lake BBEs pages
on:
workflow_dispatch:
push:
branches:
- dev
paths:
- '_data/swanlake-latest/**'
jobs:
bbe-sw-gen:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.WEBSITE_TOKEN }}
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.12
env:
GOPATH: /home/runner/work/ballerina-release
- name: Install Go module blackfriday
run: go get github.com/russross/blackfriday
- name: Install jq for json manipulation
run: sudo apt-get install jq
- name: Checkout code
uses: actions/checkout@v2
- name: Clone ballerina-release
run: git clone https://ballerina-bot:$GITHUB_TOKEN@github.com/ballerina-platform/ballerina-release.git
- name: Generate BBEs
run: |
cd ballerina-release
BALLERINA_VERSION="`jq -r '.version' ../_data/swanlake-latest/metadata.json`"
SHORT_VERSION="`jq -r '."short-version"' ../_data/swanlake-latest/metadata.json`"
curl http://dist-dev.ballerina.io/downloads/$BALLERINA_VERSION/ballerina-$BALLERINA_VERSION.zip --output ballerina.zip
if ! unzip ballerina.zip; then
exit 1
fi
go run ballerinaByExample/tools/generate.go "ballerina-${BALLERINA_VERSION}/distributions/ballerina-${SHORT_VERSION}/examples" "swan-lake" "by-example" "true" "true" "true"
- name: Remove old examples file
run: git rm -r learn/by-example
- name: Copy newly generated examples file
run: cp -r ballerina-release/by-example learn/
- name: Push changes for new BBEs
run: |
git checkout automate-bbes-$GITHUB_SHA 2>/dev/null || git checkout -b automate-bbes-$GITHUB_SHA
git pull origin dev
git config --global user.email "ballerina-bot@ballerina.org"
git config --global user.name "ballerina-bot"
git add learn/by-example
git commit --allow-empty -m 'Update Ballerina Swan Lake by examples'
git push --set-upstream origin automate-bbes-$GITHUB_SHA
echo 'Successfully pushed to automate-bbes-$GITHUB_SHA branch'
- name: Create pull request for new BBEs
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 Ballerina By Example(BBEs) pages for the new release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}