diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..900eb27 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,67 @@ +name: CI + +#on: + # pull_request + +on: + repository_dispatch: + #types: open + types: [dispatch-katacoda-scenarios] + + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: choose random polling time + id: randompoll + uses: ddradar/choose-random-action@v1.0.5 + with: + contents: | + 1 + 3 + 5 + 9 + 13 + + - name: Wait for parallel workflows to finish + uses: softprops/turnstyle@v0.1.5 + with: + poll-interval-seconds: ${{ steps.randompoll.outputs.selected }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout tutorial-compiler + uses: actions/checkout@v2 + with: + repository: devonfw-tutorials/tutorial-compiler + + - name: Checkout playbooks + uses: actions/checkout@v2 + with: + repository: devonfw-tutorials/tutorials + path: playbooks + + - uses: actions/setup-node@v2-beta + + - name: install TS + run: npm install typescript + + - name: npm install + run: npm install + + - name: run buildRun.sh + run: | + pwd + ls + sh buildRun.sh -e wiki_eclipse -e wiki_vscode -p ${{ github.event.client_payload.tutorial }} + + - name: Checkout + uses: actions/checkout@v2 + with: + path: repo + + - name: publish tutorials + run: bash repo/publishTutorials.sh diff --git a/.github/workflows/nightBuild.yml b/.github/workflows/nightBuild.yml new file mode 100644 index 0000000..747f403 --- /dev/null +++ b/.github/workflows/nightBuild.yml @@ -0,0 +1,37 @@ +name: CI + +on: + schedule: + # - cron: "*/5 * * * *" + - cron: "0 0 * * *" + + workflow_dispatch: +jobs: + nightly_build: + runs-on: ubuntu-latest + + steps: + - name: Checkout tutorial-compiler + uses: actions/checkout@v2 + with: + repository: devonfw-tutorials/tutorial-compiler + + - name: Checkout playbooks + uses: actions/checkout@v2 + with: + repository: devonfw-tutorials/tutorials + path: playbooks + + - uses: actions/setup-node@v2-beta + + - name: install TS + run: npm install typescript + + - name: npm install + run: npm install + + - name: run buildRun.sh + run: | + pwd + ls + sh buildRun.sh diff --git a/publishTutorials.sh b/publishTutorials.sh new file mode 100644 index 0000000..13139f2 --- /dev/null +++ b/publishTutorials.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# start after the folder playbooks is created in the current repository +cd playbooks +SPECIFIED_TUTORIALS=() +for dir in */; do SPECIFIED_TUTORIALS+=("${dir::-1}"); done +echo "SPECIFIED_TUTORIALS:\n" +printf "%s\n" "${SPECIFIED_TUTORIALS[@]}" +# switches to tutorials repository https://github.com/devonfw-tutorials/tutorials +cd ../repo/tutorials +ONLINE_TUTORIALS=() +for dir in */; do ONLINE_TUTORIALS+=("${dir::-1}"); done +echo "ONLINE_TUTORIALS:\n" +printf "%s\n" "${ONLINE_TUTORIALS[@]}" + +# delete tutorials, which are not specified anymore +for tutorial in "${ONLINE_TUTORIALS[@]}" +do + if [[ ! " ${SPECIFIED_TUTORIALS[@]} " =~ " ${tutorial} " ]]; then + rm -rf "${tutorial}" + echo "deleted ${tutorial} as not specified anymore in tutorials repository" + fi +done + +# switches to tutorials compiler repository https://github.com/devonfw-tutorials/tutorial-compiler (build/output/wiki) +cd ../build/output/wiki +GENERATED_TUTORIALS=() +for dir in */; do GENERATED_TUTORIALS+=("${dir::-1}"); done +echo "GENERATED_TUTORIALS:\n" +printf "%s\n" "${GENERATED_TUTORIALS[@]}" +# back to tutorials compiler repository +cd ../../.. + +# delete tutorials, which are newly generated +for tutorial in "${ONLINE_TUTORIALS[@]}" +do + if [[ ! " ${GENERATED_TUTORIALS[@]} " =~ " ${tutorial} " ]]; then + rm -rf repo/"${tutorial}" + echo "deleted ${tutorial} as this is up to be replaced by the build" + fi +done + +mkdir -p tutorials +#copy all files from * in repo/tutorials (https://github.com/devonfw-tutorials/wiki-tutorials/tutorials) +cp -r build/output/wiki/*/ repo/tutorials +cd repo/ +git add -A +git config user.email "devonfw" +git config user.name "devonfw" +git commit -m "Updated tutorials" +git pull --rebase origin/master +git push