-
Notifications
You must be signed in to change notification settings - Fork 6
104 lines (88 loc) · 4.14 KB
/
private-repo-build.yml
File metadata and controls
104 lines (88 loc) · 4.14 KB
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
# This is a basic workflow to help you get started with Actions
name: Private-Repo-Build
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
Build-Master:
if: ${{ github.ref == 'refs/heads/master' }}
# The type of runner that the job will run on
runs-on: [self-hosted, doc-build]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a set of commands using the runners shell
- name: Build the full site - main
run: |
cd ${{ runner.temp }}
mkdir -p DocHome
git clone --depth 1 https://${{ secrets.GIT_USER }}:${{ secrets.GIT_PAT }}@github.com/dynamsoft-docs/web-twain-docs.git web-twain-docs
git clone --depth 1 https://github.com/dynamsoft-docs/Docs-Template-Repo.git Docs-Template-Repo
cp -rfp ./web-twain-docs/* ./DocHome/
cp -rfp ./Docs-Template-Repo/* ./DocHome/
cd DocHome && bundle install && bundle exec jekyll build
- name: Sync files
uses: SamKirkland/FTP-Deploy-Action@4.3.0
with:
server: ${{ secrets.FTP_DYNAMSOFT_LOCAL_SERVER }}
username: ${{ secrets.FTP_DYNAMSOFT_LOCAL_USER }}
password: ${{ secrets.FTP_DYNAMSOFT_LOCAL_PASSWORD }}
port: 21
local-dir: ${{ runner.temp }}/DocHome/_site/
server-dir: /www.dynamsoft.com/web-twain/docs/
- name: Trigger Webhook
run: |
curl -X POST -H "${{ secrets.WEBHOOK_USER }}" -H "${{ secrets.WEBHOOK_TOKEN }}" -H "Content-Type: application/json" -d "[\"/web-twain/docs/*\"]" ${{ secrets.WEBHOOK_URL }}
Build-Site-Preview:
if: ${{ github.ref == 'refs/heads/preview' }}
# The type of runner that the job will run on
runs-on: [self-hosted, doc-build]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a set of commands using the runners shell
- name: Build the full site with preview branch
run: |
cd ${{ runner.temp }}
mkdir -p DocHome
git clone --depth 1 --branch preview https://${{ secrets.GIT_USER }}:${{ secrets.GIT_PAT }}@github.com/dynamsoft-docs/web-twain-docs.git web-twain-docs
git clone --depth 1 --branch preview https://github.com/dynamsoft-docs/Docs-Template-Repo.git Docs-Template-Repo
cp -rfp ./web-twain-docs/* ./DocHome/
cp -rfp ./Docs-Template-Repo/* ./DocHome/
sed -i -e "1,3s/blob\/master$/blob\/preview/" \
-e "1,3s/blob\/main$/blob\/preview/" ${{ runner.temp }}/DocHome/_config.yml
cd DocHome && bundle install && bundle exec jekyll build
- name: 'Create Tar files'
run: tar -czvf web-twain-docs.tar.gz -C ${{ runner.temp }}/DocHome/_site .
- name: Upload the built site as a single artifact
uses: actions/upload-artifact@v3
with:
name: web-twain-docs
path: web-twain-docs.tar.gz
retention-days: 2
Sync-To-Testing:
# The type of runner that the job will run on
runs-on: [self-hosted, upload-test]
needs: Build-Site-Preview
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a set of commands using the runners shell
- name: Download the artifact
uses: actions/download-artifact@v3
with:
name: web-twain-docs
- name: 'Extract Tar files'
shell: cmd
run: |
mkdir ${{ runner.temp }}\DocHome\_site
tar -xzf web-twain-docs.tar.gz -C ${{ runner.temp }}\DocHome\_site
- name: Sync files
uses: SamKirkland/FTP-Deploy-Action@4.3.0
with:
server: ${{ secrets.FTP_TEST_SITE_SERVER }}
username: ${{ secrets.FTP_TEST_SITE_USER }}
password: ${{ secrets.FTP_TEST_SITE_PASSWORD }}
port: 7500
local-dir: ${{ runner.temp }}\DocHome\_site/
server-dir: /www.dynamsoft.com/web-twain/docs/