Skip to content

Instantly share code, notes, and snippets.

@suru-dissanaike
Created June 22, 2021 18:06
Show Gist options
  • Save suru-dissanaike/79db00b941dcfcb386daa6ebf354cc63 to your computer and use it in GitHub Desktop.
Save suru-dissanaike/79db00b941dcfcb386daa6ebf354cc63 to your computer and use it in GitHub Desktop.
image: node:14.16.1
stages:
- ci-report-wiki
ci-report-wiki:
stage: ci-report-wiki
variables:
# specify the filename you want to modify
FILENAME: "ci-report.md"
script:
# define URL for the wiki in terms of project-agnostic predefined variables
- export WIKI_URL="${CI_SERVER_PROTOCOL}://project_${CI_PROJECT_ID}_bot:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/${CI_PROJECT_PATH}.wiki.git"
# Run node application
- yarn install
- yarn build
- yarn start --group "himinds-boosting-innovation"
- ls -all
- pwd
# clone this project's wiki under /tmp
- rm -rf "/tmp/${CI_PROJECT_NAME}.wiki"
- cd /tmp
- git clone "${WIKI_URL}"
# enter the cloned repo
- cd "${CI_PROJECT_NAME}.wiki"
- cp "/builds/${CI_PROJECT_PATH}/$FILENAME" .
- ls -all
# set committer info
- git config user.name "$GITLAB_USER_NAME"
- git config user.email "$GITLAB_USER_EMAIL"
# commit the file
- git add "$FILENAME"
- git commit -m "Auto-updated file in CI"
# push the change back to the master branch of the wiki
- git push origin "HEAD:master"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment