forked from ballerina-platform/ballerina-dev-website
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (71 loc) · 3.1 KB
/
update_ballerina_by_example_on_demand.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
name: Create PR for new Swan Lake BBEs pages on demand
on:
workflow_dispatch:
inputs:
artifact:
description: 'Artifact ID'
required: true
version:
description: 'Artifact version'
required: true
short_version:
description: 'Artifact short version'
required: true
code_name:
description: 'Code name of the distribution'
required: true
default: 'swan-lake'
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
with:
ref: master
- 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=${{ github.event.inputs.version }}
SHORT_VERSION=${{ github.event.inputs.short_version }}
CODE_NAME=${{ github.event.inputs.code_name }}
wget --header="Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/ballerina-platform/ballerina-distribution/actions/artifacts/${{ github.event.inputs.artifact }}/zip -O "ballerina.zip"
unzip ballerina.zip
unzip ballerina-${BALLERINA_VERSION}-${CODE_NAME}.zip
cp ballerina-${BALLERINA_VERSION}-${CODE_NAME}/distributions/ballerina-${SHORT_VERSION}/examples/index.json ../_data/all-bbes.json
go run ballerinaByExample/tools/generate.go "ballerina-${BALLERINA_VERSION}-${CODE_NAME}/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 config --global user.email "ballerina-bot@ballerina.org"
git config --global user.name "ballerina-bot"
git add _data/all-bbes.json
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 -b master -m '[Automated] Update Ballerina By Example(BBEs) pages'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}