-
Notifications
You must be signed in to change notification settings - Fork 1.5k
47 lines (44 loc) · 1.52 KB
/
reduce_readme.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
name: JBoss EAP 8.0 Quickstarts Update 'README.adoc's
on:
push:
branches:
- 8.0.x
# Only run the latest job
concurrency:
group: '${{ github.workflow }} @ ${{ github.ref || github.run_id }}'
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Asciidoctor Reducer
run: sudo gem install asciidoctor-reducer
- name: Reduce README
run: |
CURRENT_DIR="$( pwd -P)"
#Get a list of subdirectories that don't start with a .
subdirs=`find . -maxdepth 1 -type d ! -iname ".*"`
#Loop over the subdirectories
for subdir in $subdirs
do
cd $subdir
#Check if the directory contains README-source.adoc
if [ -e README-source.adoc ]
then
#Get the dirname to define artifactId in the adoc
ARTIFACT_ID=":artifactId: $(basename `pwd`)"
#Use asciidoctor-reducer to create a flattened README.adoc
asciidoctor-reducer --preserve-conditionals -o README.adoc README-source.adoc
#Insert the directory name with env-github def so that this only affects GitHub rendering
sed -i "1s/^/ifdef::env-github[]\n$ARTIFACT_ID\nendif::[]\n\n/" README.adoc
fi
cd $CURRENT_DIR
done
#Reduce root README
asciidoctor-reducer --preserve-conditionals -o README.adoc README-source.adoc
- name: Commit and Push README
uses: EndBug/add-and-commit@v9
with:
add: '*.adoc'