xref: /plugin/combo/.github/bootstrap.sh (revision 04fd306c7c155fa133ebb3669986875d65988276)
1#!/bin/bash
2# https://docs.github.com/en/actions/learn-github-actions/contexts#example-usage-of-the-github-context
3# https://docs.github.com/en/actions/learn-github-actions/variables#using-the-vars-context-to-access-configuration-variable-values
4# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
5if [ "${GITHUB_EVENT_NAME}" == 'pull_request' ]; then
6  # The head ref or source branch of the pull request in a workflow run.
7  # This property is only set when the event that triggers a workflow run is either pull_request or pull_request_target.
8  # For example, feature-branch-1
9  BUILD_BRANCH=${GITHUB_HEAD_REF}
10  # The name of the base ref or target branch of the pull request in a workflow run.
11  # This is only set when the event that triggers a workflow run is either pull_request or pull_request_target.
12  # For example, main
13  BUILD_TARGET_BRANCH=${GITHUB_BASE_REF}
14  echo -e "\nPull request from the branch (${BUILD_BRANCH}) to the branch (${BUILD_TARGET_BRANCH})"
15else
16  # The short ref name of the branch or tag that triggered the workflow run.
17  # This value matches the branch or tag name shown on GitHub.
18  # For example, feature-branch-1 or 57/merge for a pull request
19  BUILD_BRANCH=${GITHUB_REF_NAME}
20fi
21
22# ${TRAVIS_BRANCH} in a PR build is the target branch
23# ${TRAVIS_PULL_REQUEST_BRANCH} is not empty in a PR build
24#if [ "${TRAVIS_PULL_REQUEST_BRANCH}" == "" ]; then
25#  BUILD_BRANCH=${TRAVIS_BRANCH}
26#  echo -e "\nPush Build on the branch (${BUILD_BRANCH})"
27#else
28#  BUILD_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH}
29#  echo -e "\nPull Request Build from the branch (${TRAVIS_PULL_REQUEST_BRANCH})"
30#fi
31
32echo -e "\nGet boot.sh from from the branch (${BUILD_BRANCH})"
33curl -H "Authorization: token ${TOKEN}" -o "boot.sh" "https://raw.githubusercontent.com/ComboStrap/combo_test/${BUILD_BRANCH}/resources/script/ci/boot.sh"
34echo -e "\nRun boot.sh"
35chmod +x boot.sh
36source boot.sh
37