xref: /template/strap/.github/bootstrap.sh (revision 04fd306c7c155fa133ebb3669986875d65988276)
1977ce05dSgerardnico#!/bin/bash
2977ce05dSgerardnico# https://docs.github.com/en/actions/learn-github-actions/contexts#example-usage-of-the-github-context
3977ce05dSgerardnico# https://docs.github.com/en/actions/learn-github-actions/variables#using-the-vars-context-to-access-configuration-variable-values
4977ce05dSgerardnico# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
5*04fd306cSNickeauif [ "${GITHUB_EVENT_NAME}" == 'pull_request' ]; then
6977ce05dSgerardnico  # The head ref or source branch of the pull request in a workflow run.
7977ce05dSgerardnico  # This property is only set when the event that triggers a workflow run is either pull_request or pull_request_target.
8977ce05dSgerardnico  # For example, feature-branch-1
9*04fd306cSNickeau  BUILD_BRANCH=${GITHUB_HEAD_REF}
10977ce05dSgerardnico  # The name of the base ref or target branch of the pull request in a workflow run.
11977ce05dSgerardnico  # This is only set when the event that triggers a workflow run is either pull_request or pull_request_target.
12977ce05dSgerardnico  # For example, main
13*04fd306cSNickeau  BUILD_TARGET_BRANCH=${GITHUB_BASE_REF}
14*04fd306cSNickeau  echo -e "\nPull request from the branch (${BUILD_BRANCH}) to the branch (${BUILD_TARGET_BRANCH})"
15*04fd306cSNickeauelse
16977ce05dSgerardnico  # The short ref name of the branch or tag that triggered the workflow run.
17977ce05dSgerardnico  # This value matches the branch or tag name shown on GitHub.
18*04fd306cSNickeau  # For example, feature-branch-1 or 57/merge for a pull request
19*04fd306cSNickeau  BUILD_BRANCH=${GITHUB_REF_NAME}
20*04fd306cSNickeaufi
21*04fd306cSNickeau
22*04fd306cSNickeau# ${TRAVIS_BRANCH} in a PR build is the target branch
23*04fd306cSNickeau# ${TRAVIS_PULL_REQUEST_BRANCH} is not empty in a PR build
24*04fd306cSNickeau#if [ "${TRAVIS_PULL_REQUEST_BRANCH}" == "" ]; then
25*04fd306cSNickeau#  BUILD_BRANCH=${TRAVIS_BRANCH}
26*04fd306cSNickeau#  echo -e "\nPush Build on the branch (${BUILD_BRANCH})"
27*04fd306cSNickeau#else
28*04fd306cSNickeau#  BUILD_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH}
29*04fd306cSNickeau#  echo -e "\nPull Request Build from the branch (${TRAVIS_PULL_REQUEST_BRANCH})"
30*04fd306cSNickeau#fi
31*04fd306cSNickeau
32*04fd306cSNickeauecho -e "\nGet boot.sh from from the branch (${BUILD_BRANCH})"
33977ce05dSgerardnicocurl -H "Authorization: token ${TOKEN}" -o "boot.sh" "https://raw.githubusercontent.com/ComboStrap/combo_test/${BUILD_BRANCH}/resources/script/ci/boot.sh"
34*04fd306cSNickeauecho -e "\nRun boot.sh"
35977ce05dSgerardnicochmod +x boot.sh
36977ce05dSgerardnicosource boot.sh
37