Skip to content

Merge pull request #555 from victordrose/feature/azure-ci-pipeline #229

Merge pull request #555 from victordrose/feature/azure-ci-pipeline

Merge pull request #555 from victordrose/feature/azure-ci-pipeline #229

env:
BUILD_USER: ${{ secrets.BUILD_USER }}
BUILD_USER_PASSWD: ${{ secrets.BUILD_USER_PASSWD }}
BUILD_USER_EMAIL: ${{ secrets.BUILD_USER_EMAIL }}
on:
push:
branches:
- master
name: Sync Wiki 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: Generate build number
uses: einaregilsson/build-number@v3
with:
token: ${{secrets.github_token}}
- 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: Copy docs and consolidate links
run: |
cp -rf ${REPO_SOURCE}/documentation/* ${REPO_DEST}/
cd ${REPO_DEST}
../${REPO_SOURCE}/.github/workflows/scripts/rename-documentation-for-wiki.sh
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 .
git commit -m "${REPO_SOURCE} documentation | GitHub Actions build number $BUILD_NUMBER"
git remote add origin-wiki "https://${BUILD_USER}:${BUILD_USER_PASSWD}@github.com/${ORG}/${REPO_DEST}.git"
git push origin-wiki master