-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (124 loc) · 4.34 KB
/
dita-ot-build-actions.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: DITA Workflow
on:
push:
branches:
- dita
jobs:
build-html:
name: Generate html5 with latest DITA Open Toolkit # Human-readable job name
runs-on: ubuntu-latest
steps:
- name: Check out the dita branch
uses: actions/checkout@v4
with:
ref: dita
- name: Delete out folder
run: |
echo "Deleting out folder"
rm -rf out
- name: Build HTML5
uses: dita-ot/dita-ot-action@master
with:
build: |
set -e
echo " dita --input=$(pwd)/content/en/orange-heart-master.ditamap --format=html5 --verbose --propertyfile=$(pwd)/resources/build.properties -Dargs.input.dir=$(pwd) "
dita --input=$(pwd)/content/en/orange-heart-master.ditamap --format=html5 --verbose --propertyfile=$(pwd)/resources/build.properties -Dargs.input.dir=$(pwd) 2>&1 | tee log.txt
- name: Upload log file as an artifact
uses: actions/upload-artifact@v4
with:
name: build-log-html5-txt
path: log.txt
- name: Archive the 'out' folder
run: |
set -e
tar -czf out.tar.gz out
- name: Upload 'out' folder archive
uses: actions/upload-artifact@v4
with:
name: out-html5-archive
path: out.tar.gz
- name: List build output
run: ls -R out
- name: Configure git
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
- name: Commit and push changes
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git add out
if git diff-index --quiet HEAD; then
echo "No changes to commit"
else
git commit -m "Github workflow ran DITA OT and generated html5 to out folder"
git push https://${{ secrets.GH_TOKEN }}@github.com/yetessam/orange-heart-image-addressing.git dita
fi
- name: Summarize build
run: |
echo "### Summary " >> $GITHUB_STEP_SUMMARY
echo "$(cat log.txt)" >> $GITHUB_STEP_SUMMARY
switch-branch:
name: Switch to Dev Branch and Configure HTML # Human-readable name for the job
runs-on: ubuntu-latest
needs: build-html # Indicates that this job depends on the build-html job
steps:
- name: Check out the dev branch
uses: actions/checkout@v4
with:
ref: dev
- name: Download 'out-html5-archive' artifact
uses: actions/download-artifact@v4
with:
name: out-html5-archive
path: .
- name: Extract the 'out' folder
run: |
tar -xzf out.tar.gz
ls -laR
- name: Create src folder if it doesn't exist
run: |
mkdir -p ./src
ls -la
- name: Python
run: | # Come back here
echo "Installing Python and dependencies"
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies and run Python script
run: |
set -e
echo "Listing contents of $(pwd):"
ls -laR
python -m venv venv
source venv/bin/activate
pip install beautifulsoup4
echo "Listing contents of $(pwd):"
ls -laR
- name: Run Python script
run: |
set -e
source venv/bin/activate
python python/main_script.py --out_dir $(pwd)/out --src_dir $(pwd)/src
- name: List directory contents after running Python script
run: |
set -e
echo "Listing contents of $(pwd):"
ls -l
echo "Contents of src directory:"
ls -la src
- name: Remove venv, tar file and out folder
run: |
rm -rf venv/
rm -f out.tar.gz
rm -rf out/
echo "Deleting out folder and out.tar.gz file"
- name: Commit and push changes to dev branch
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
git add --verbose --force src
git commit -m "Copy files from DITA OT build to src "
git push origin dev