From f2a079bea2956585adf3e4045c7e537dfa76a21d Mon Sep 17 00:00:00 2001 From: Andrei Gherzan <andrei.gherzan@huawei.com> Date: Fri, 26 Mar 2021 16:48:27 +0000 Subject: [PATCH] .gitlab-ci.yml: Flatten repository on openharmony-readthedocs-aggregated This is currently only done for the main branch. For every new push to this branch, the pipeline will push a flatten version of it on the main branch of openharmony-readthedocs-aggregated referencing the origin branch and SHA in the commit log. Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com> --- .gitlab-ci.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e685fbd..758f277 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,19 +72,20 @@ deploy: - *doc-workspace-do - git clone https://user:$OHOS_AGGREGATED_DOCS_TOKEN@git.ostc-eu.org/OSTC/infrastructure/openharmony-readthedocs-aggregated.git - cd openharmony-readthedocs-aggregated - - git checkout test # TODO: switch to main / master - - find . -name '*.rst' -delete || true - - tar -c --dereference -C ../experimental . | tar -x - # Clean up files we don't want in the aggregated view - - rm -f .rst-aggregator Makefile + - git checkout origin/main # only main for now - needs to match the rules + - find . -maxdepth 1 -not -path ./.git -not -path . -exec rm -rf {} \; + - tar -c --dereference -C .. --exclude openharmony-readthedocs-aggregated --exclude ./.git . | tar -x # Commit and push back, if something changed. - - git config --local user.name "OpenHarmony Docs Build System" - - git config --local user.email "nobody@example.org" - - git add . - | - if ! git status; then - git commit -sm "Automatic snapshot update"; - git push origin test; - fi + if [ -n "$(git status -s)" ]; then + msg="docs repository snapshot - $CI_COMMIT_BRANCH:$CI_COMMIT_SHA"; + git config --local user.name "OpenHarmony CI"; + git config --local user.email "ci@ostc-eu.org"; + git add -A + git commit -sm "$msg"; + git push origin HEAD:main; + else + echo "Nothing new to commit."; + fi rules: - - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH == "main"' -- GitLab