Skip to content

Commit

Permalink
doc: add .sparrow-example-ci.yml example
Browse files Browse the repository at this point in the history
  • Loading branch information
WGrape committed Mar 4, 2024
1 parent 67a60e8 commit e378cb7
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions template/.sparrow-example-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# if you use github, you should move this file to .github/workflows
name: github-ci
on:
push:
branches:
- main
- test

jobs:
CIManager:
runs-on: ubuntu-latest
env:
# ========================= CI =========================
# [stage] = pre
CI_STAGE_PRE_JOB_PRE_CHECK_SWITCH: "ON"
CI_STAGE_PRE_JOB_PRE_CHECK_CMD: "docker-compose --version"
CI_STAGE_PRE_JOB_PRE_INSTALL_SWITCH: "ON"
CI_STAGE_PRE_JOB_PRE_INSTALL_CMD: |
cd sparrow && bash _install.sh && bash ./sparrow startone go && cd ..
mkdir -p ./sparrow/go/data/mapserver
rsync -av --exclude='../mapserver/sparrow/' ../mapserver/ "./sparrow/go/data/mapserver"
ls ./sparrow/go/data
# [stage] = test
CI_STAGE_TEST_JOB_UNIT_TEST_SWITCH: "ON"
CI_STAGE_TEST_JOB_UNIT_TEST_CMD: "cd pkg/util && go test -v ."
CI_STAGE_TEST_JOB_CHECK_CODE_SWITCH: "ON"
CI_STAGE_TEST_JOB_CHECK_CODE_CMD: ""
# [stage] = build
CI_STAGE_BUILD_JOB_LOCAL_BUILD_SWITCH: "ON"
CI_STAGE_BUILD_JOB_LOCAL_BUILD_CMD: |
env="test"
docker exec -it sparrow_container_${env}_go bash -c "cd /var/data/go/mapserver && go mod tidy && nohup go run mapserver.go -f etc/application.${env}.yaml &"
CI_STAGE_BUILD_JOB_APIDOC_GEN_SWITCH: "ON"
CI_STAGE_BUILD_JOB_APIDOC_GEN_CMD: ""
# ========================= CD =========================
# [stage] = deploy
CD_STAGE_DEPLOY_JOB_SSH_SWITCH: "ON"
CD_STAGE_DEPLOY_JOB_SSH_CMD: ""
# [stage] = monitor
CD_STAGE_MONITOR_JOB_API_TEST_SWITCH: "ON"
CD_STAGE_MONITOR_JOB_API_TEST_CMD: ""
CD_STAGE_MONITOR_JOB_HEALTH_CHECK_SWITCH: "ON"
CD_STAGE_MONITOR_JOB_HEALTH_CHECK_CMD: ""

steps:
- uses: actions/checkout@v1
- run: |
printf "================ Start to Boot CIManager ================\n"
git clone https://github.com/wgrape/CIManager.git
cp -an ./CIManager/.pipeline ./
rm -rf ./CIManager
cd .pipeline
printf "================ End Boot ================\n\n"
printf "================ Debug Start ================\n\n"
show_env(){
echo "1. cat /proc/version="$(cat /proc/version)
echo "2. pwd="$(pwd)
echo "3. ls="$(ls -a)
}
show_env
printf "================ End Debug ================\n\n"
printf "\e[36m>>>>>>>>>>> Start Pipeline\e[0m\n\n"
# you can run sudo with the -E/--preserve-env switch, sudo -E/--preserve-env ..., which retains environment variables.
sudo --preserve-env bash start.sh
printf "\e[36m<<<<<<<<<<< End Pipeline\e[0m"

0 comments on commit e378cb7

Please sign in to comment.