|
| 1 | +stages: |
| 2 | + - build |
| 3 | + - deploy |
| 4 | + |
| 5 | +variables: |
| 6 | + GIT_STRATEGY: clone |
| 7 | + |
| 8 | +# before each job, we need to check if this job is filtered by bot stage/job filter |
| 9 | +.apply_bot_filter: &apply_bot_filter |
| 10 | + python $APPLY_BOT_FILTER_SCRIPT || exit 0 |
| 11 | + |
| 12 | +before_script: |
| 13 | + - mkdir -p ~/.ssh |
| 14 | + - chmod 700 ~/.ssh |
| 15 | + - echo -n $GITLAB_KEY >> ~/.ssh/id_rsa_base64 |
| 16 | + - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa |
| 17 | + - chmod 600 ~/.ssh/id_rsa |
| 18 | + - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config |
| 19 | + |
| 20 | +.do_nothing_before: |
| 21 | + before_script: &do_nothing_before |
| 22 | + # apply bot filter in before script |
| 23 | + - *apply_bot_filter |
| 24 | + - echo "Not setting up GitLab key, not fetching submodules" |
| 25 | + - source tools/ci/configure_ci_environment.sh |
| 26 | + |
| 27 | +.build_template: &build_template |
| 28 | + stage: build |
| 29 | + image: ci_test |
| 30 | + tags: |
| 31 | + - build |
| 32 | + |
| 33 | +build_ssc: |
| 34 | + <<: *build_template |
| 35 | + artifacts: |
| 36 | + paths: |
| 37 | + - ./SSC/ssc_bin |
| 38 | + expire_in: 6 mos |
| 39 | + script: |
| 40 | + - git clone $GITLAB_SSH_SERVER/yinling/SSC.git |
| 41 | + - cd SSC |
| 42 | + # try checkout same branch |
| 43 | + - git checkout ${CI_BUILD_REF_NAME} || echo "Using default branch..." |
| 44 | + - chmod +x gen_misc_rtos.sh |
| 45 | + - ./gen_misc_rtos.sh |
| 46 | + |
| 47 | +push_master_to_github: |
| 48 | + stage: deploy |
| 49 | + image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG |
| 50 | + tags: |
| 51 | + - deploy |
| 52 | + only: |
| 53 | + - master |
| 54 | + - /^release\/v/ |
| 55 | + - /^v\d+\.\d+(\.\d+)?($|-)/ |
| 56 | + when: on_success |
| 57 | + dependencies: [] |
| 58 | + variables: |
| 59 | + GITHUB_PUSH_REFS: refs/remotes/origin/release refs/remotes/origin/master |
| 60 | + before_script: *do_nothing_before |
| 61 | + script: |
| 62 | + - mkdir -p ~/.ssh |
| 63 | + - chmod 700 ~/.ssh |
| 64 | + - echo -n $GH_PUSH_KEY > ~/.ssh/id_rsa_base64 |
| 65 | + - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa |
| 66 | + - chmod 600 ~/.ssh/id_rsa |
| 67 | + - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config |
| 68 | + - git remote remove github &>/dev/null || true |
| 69 | + - git remote add github git@github.com:espressif/ESP8266_RTOS_SDK.git |
| 70 | + # What the next line of script does: goes through the list of refs for all branches we push to github, |
| 71 | + # generates a snippet of shell which is evaluated. The snippet checks CI_COMMIT_SHA against the SHA |
| 72 | + # (aka objectname) at tip of each branch, and if any SHAs match then it checks out the local branch |
| 73 | + # and then pushes that ref to a corresponding github branch |
| 74 | + - eval $(git for-each-ref --shell bash --format 'if [ $CI_COMMIT_SHA == %(objectname) ]; then git checkout -B %(refname:strip=3); git push --follow-tags github %(refname:strip=3); fi;' $GITHUB_PUSH_REFS) |
0 commit comments