-
Notifications
You must be signed in to change notification settings - Fork 70
79 lines (79 loc) · 3.35 KB
/
devonfw-sync-docs.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
env:
REPO_CONSOLIDATE: "devonfw-guide"
BUILD_USER: ${{ secrets.BUILD_USER }}
BUILD_USER_PASSWD: ${{ secrets.BUILD_USER_PASSWD }}
BUILD_USER_EMAIL: ${{ secrets.BUILD_USER_EMAIL }}
on:
push:
branches:
- master
paths:
- 'documentation/**'
name: Sync Docs
jobs:
update-wiki:
if: ${{ startsWith(github.repository, 'devonfw/') }}
runs-on: ubuntu-latest
steps:
- name: setup variables
run: |
echo "ORG=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV
echo "REPO_SOURCE=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
echo "REPO_DEST=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}').wiki" >> $GITHUB_ENV
shell: bash
- name: Checkout ${REPO_SOURCE} Repository
run: git clone https://github.com/${ORG}/${REPO_SOURCE}.git ${REPO_SOURCE}
- name: Checkout ${REPO_DEST} Repository
run: git clone https://github.com/${ORG}/${REPO_DEST}.git ${REPO_DEST}
- name: Checkout ${REPO_CONSOLIDATE} Repository
run: git clone https://github.com/${ORG}/${REPO_CONSOLIDATE}.git ${REPO_CONSOLIDATE}
- name: Copy docs and consolidate links
run: |
cp -rf ${REPO_SOURCE}/documentation/* ${REPO_DEST}/
cd ${REPO_DEST}
grep -lr "link:[a-zA-Z0-9_.-]*.asciidoc.*" .| xargs -r sed -i "s/.asciidoc//g"
echo ">"
git diff-index --quiet HEAD & git status -s
echo "<"
git status
echo ">"
git diff-index --quiet HEAD & git status -s
echo "<"
echo "TO_BE_CANCELLED=$(if [[ $(git diff-index --quiet HEAD & git status -s) ]]; then echo "false"; else echo "true"; fi)" >> $GITHUB_ENV
echo "$TO_BE_CANCELLED"
- name: setup git user
if: ${{ env.TO_BE_CANCELLED == 'false' }}
run: |
git config --global user.email ${BUILD_USER_EMAIL}
git config --global user.name ${BUILD_USER}
- name: Sync Wiki
if: ${{ env.TO_BE_CANCELLED == 'false' }}
run: |
cd ${REPO_DEST}
git status
git add -A --verbose
git status
git commit -am "${REPO_SOURCE} documentation | GitHub Actions $GITHUB_WORKFLOW $GITHUB_RUN_NUMBER"
git remote add origin-wiki "https://${BUILD_USER}:${BUILD_USER_PASSWD}@github.com/${ORG}/${REPO_DEST}.git"
git push origin-wiki master
- name: Sync devonfw guide
if: ${{ env.TO_BE_CANCELLED == 'false' }}
run: |
cd ${REPO_CONSOLIDATE}
if [ ! -d ${REPO_DEST} ]; then git submodule add https://github.com/${ORG}/${REPO_DEST}.git; fi;
git submodule init
git submodule update --recursive --remote
cd ${REPO_DEST}
git checkout master
git pull
cd ..
git add .
git commit -am "${REPO_SOURCE} documentation | GitHub Actions $GITHUB_WORKFLOW $GITHUB_RUN_NUMBER"
git remote add origin-wiki "https://${BUILD_USER}:${BUILD_USER_PASSWD}@github.com/${ORG}/${REPO_CONSOLIDATE}.git"
git push origin-wiki master
- name: Trigger Update devonfw-guide on success
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GHA_TOKEN }}
repository: devonfw/devonfw-guide
event-type: dispatch-update-guide