diff --git a/.github/workflows/main_release.yml b/.github/workflows/main_release.yml new file mode 100644 index 00000000..f419aba2 --- /dev/null +++ b/.github/workflows/main_release.yml @@ -0,0 +1,21 @@ +name: engine-release + +on: + push: + branches: main + +jobs: + engine-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Run a multi-line script + timeout-minutes: 60 + env: + GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }} + GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} + GITLAB_PERSONAL_TOKEN: ${{ secrets.GITLAB_PERSONAL_TOKEN }} + run: | + export GITHUB_BRANCH=main + export GITHUB_COMMIT_ID=$GITHUB_SHA + ./helper.sh release diff --git a/helper.sh b/helper.sh index ffe0a0b6..42d5802d 100755 --- a/helper.sh +++ b/helper.sh @@ -16,6 +16,22 @@ function variable_not_found() { exit 1 } +function release() { + test -z $GITLAB_PROJECT_ID && variable_not_found "GITLAB_PROJECT_ID" + test -z $GITLAB_TOKEN && variable_not_found "GITLAB_TOKEN" + test -z $GITLAB_PERSONAL_TOKEN && variable_not_found "GITLAB_PERSONAL_TOKEN" + test -z $GITHUB_BRANCH && variable_not_found "GITHUB_BRANCH" + GITLAB_REF="main" + + echo "Requesting Gitlab pipeline" + pipeline_id=$(curl -s -X POST -F "token=$GITLAB_TOKEN" -F "ref=$GITLAB_REF" -F "variables[GITHUB_COMMIT_ID]=$GITHUB_COMMIT_ID" -F "variables[GITHUB_ENGINE_BRANCH_NAME]=$GITHUB_BRANCH" -F "variables[TESTS_TYPE]=$TESTS_TYPE" https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/trigger/pipeline | jq --raw-output '.id') + if [ $(echo $pipeline_id | egrep -c '^[0-9]+$') -eq 0 ] ; then + echo "Pipeline ID is not correct, we expected a number and got: $pipeline_id" + exit 1 + fi + echo "Pipeline ID: $pipeline_id" +} + function run_tests() { TESTS_TYPE=$1 test -z $GITLAB_PROJECT_ID && variable_not_found "GITLAB_PROJECT_ID" @@ -99,9 +115,12 @@ fast_tests) full_tests) run_tests full ;; +release) + release + ;; *) echo "Usage:" echo "$0 fast_tests: run fast tests" - echo "$0 full_tests: run fast tests (with cloud providers check)" + echo "$0 full_tests: run full tests (with cloud providers check)" ;; esac