remove travis remains (#3051)

This commit is contained in:
Denys Vuika 2023-03-14 17:01:56 -04:00 committed by GitHub
parent 680319596a
commit eba0f9aef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 28 additions and 527 deletions

View File

@ -3,7 +3,6 @@ e2e-output
dist dist
coverage coverage
.github .github
.travis
.vscode .vscode
scripts scripts
app/src/assets/i18n app/src/assets/i18n

View File

@ -37,4 +37,4 @@ runs:
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
- name: Publish image - name: Publish image
shell: bash shell: bash
run: ./scripts/travis/deploy/publish.sh "${{ inputs.domain }}" "$REPO_SLUG" "${{ inputs.username }}" "${{ inputs.password }}" "$TAG_VERSION" "${{ inputs.branch_name }}" "${{ inputs.dry-run }}" run: ./scripts/gh/docker-publish.sh "${{ inputs.domain }}" "$REPO_SLUG" "${{ inputs.username }}" "${{ inputs.password }}" "$TAG_VERSION" "${{ inputs.branch_name }}" "${{ inputs.dry-run }}"

View File

@ -15,31 +15,34 @@ on:
default: alfresco-applications default: alfresco-applications
env: env:
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
TRAVIS_COMMIT: ${{ github.sha }} GH_COMMIT: ${{ github.sha }}
TRAVIS_BUILD_NUMBER: ${{ github.run_id }} GH_BUILD_NUMBER: ${{ github.run_id }}
NODE_OPTIONS: "--max-old-space-size=5120" NODE_OPTIONS: "--max-old-space-size=5120"
jobs: jobs:
trigger_aca_upstream: trigger_aca_upstream:
name: Trigger ACA upstream name: Trigger ACA Upstream
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout Repository
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: install NPM
- name: Setup Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
cache: 'npm' cache: 'npm'
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.35.0 - uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.35.0
with: with:
username: ${{ vars.BOT_GITHUB_USERNAME }} username: ${{ vars.BOT_GITHUB_USERNAME }}
email: ${{ vars.BOT_GITHUB_EMAIL }} email: ${{ vars.BOT_GITHUB_EMAIL }}
global: true global: true
- name: Trigger upstream
- name: Trigger Upstream
shell: bash shell: bash
run: | run: |
npm install github-api npm install github-api
./scripts/travis/update/update-project.sh -p $TRAVIS_BUILD_NUMBER -t $GH_TOKEN -v alpha -c $TRAVIS_COMMIT -r ${{ inputs.repo_to_update || 'alfresco-applications' }} ./scripts/gh/update/update-project.sh -p $GH_BUILD_NUMBER -t $GH_TOKEN -v alpha -c $GH_COMMIT -r ${{ inputs.repo_to_update || 'alfresco-applications' }}

View File

@ -1,33 +0,0 @@
{
"standalone": {
"projectRoot": ".."
},
"deploy": {
"releaseVersion": "",
"tagAliases": [],
"tagVersionSuffix": ""
},
"scripts": {
"prebuild": [
{
"command": "./scripts/local/check-for-extra-node-modules"
},
{
"command": "mkdir",
"args": [
"-p",
"$THIS_PROJECT_ROOT_PATH/.tmp"
]
},
{
"command": "cp",
"args": [
"$THIS_PROJECT_SOURCE_ROOT_PATH/app.config.json.tpl",
"$THIS_PROJECT_ROOT_PATH/.tmp/app.config.json"
]
}
],
"postinstall": [
]
}
}

View File

@ -2,36 +2,40 @@
Title: Publish to npm Title: Publish to npm
--- ---
# Create a new library ## Create a new library
New library can be created using standard `ng` command New library can be created using standard `ng` command
e.g. if we would like to create `aca-new-lib` we need to run the following: e.g. if we would like to create `aca-new-lib` we need to run the following:
``` ```sh
ng generate @schematics/angular:library aca-new-lib ng generate @schematics/angular:library aca-new-lib
``` ```
# Publish library ## Publish library
### Build library
## Build library
In order to publish new library, we need to build it first. You need to add build of your library to `build-libs` command in `package.json` In order to publish new library, we need to build it first. You need to add build of your library to `build-libs` command in `package.json`
``` ```sh
"build-libs": "ng build aca-shared && ng build aca-new-lib", "build-libs": "ng build aca-shared && ng build aca-new-lib",
``` ```
## Update publish script ### Update publish script
If we would like to publish the new library we need to update `scripts/ci/npm/publish-libs.sh`
If we would like to publish the new library we need to update `scripts/gh/npm-publish.sh`
The only thing that need to be done is to update `PROJECTS` variable by adding your library name i.e. The only thing that need to be done is to update `PROJECTS` variable by adding your library name i.e.
``` ```sh
PROJECTS=( PROJECTS=(
'aca-shared', 'aca-shared',
'aca-new-lib' 'aca-new-lib'
); );
``` ```
# Caveats
## Caveats
- The versions of libraries are updated automatically by the script (should not be done manually) - The versions of libraries are updated automatically by the script (should not be done manually)
- In travis setting you can find `PUBLISH_PROJECTS` variable, which can be used for enabling dry mode when running the publish command

View File

@ -1,10 +1,10 @@
const buildNumber = () => { const buildNumber = () => {
let buildNumber = process.env.TRAVIS_BUILD_NUMBER; let buildNumber = process.env.GH_BUILD_NUMBER;
if (!buildNumber) { if (!buildNumber) {
process.env.TRAVIS_BUILD_NUMBER = Date.now(); process.env.GH_BUILD_NUMBER = Date.now();
} }
return process.env.TRAVIS_BUILD_NUMBER; return process.env.GH_BUILD_NUMBER;
} }
module.exports = buildNumber; module.exports = buildNumber;

View File

@ -1,75 +0,0 @@
#!/usr/bin/env node
const program = require('commander');
require('dotenv').config({ path: process.env.ENV_FILE });
const fs = require('fs');
const APP_CONFIG_ECM_HOST = process.env.APP_CONFIG_ECM_HOST;
const APP_CONFIG_BPM_HOST = process.env.APP_CONFIG_BPM_HOST;
const APP_CONFIG_OAUTH2_HOST = process.env.APP_CONFIG_OAUTH2_HOST || 'oauth-host-default-replaced-value';
const APP_CONFIG_IDENTITY_HOST = process.env.APP_CONFIG_IDENTITY_HOST || 'identity-host-default-replaced-value';
const APP_CONFIG_NOTIFICATION_LAST = parseInt(process.env.APP_CONFIG_NOTIFICATION_LAST, 10) || 2000;
const APP_CONFIG_PLUGIN_AOS = process.env.APP_CONFIG_PLUGIN_AOS || true;
const options = {
apiHost: {
flags: '-a, --api-host',
description:
'set bpmHost=APP_CONFIG_BPM_HOST, ecmHost=APP_CONFIG_ECM_HOST, aosHost = APP_CONFIG_ECM_HOST if present',
set: (appConfig) => {
appConfig.bpmHost = APP_CONFIG_BPM_HOST;
appConfig.ecmHost = APP_CONFIG_ECM_HOST;
appConfig.baseShareUrl = appConfig.baseShareUrl.replace('{protocol}//{hostname}{:port}', APP_CONFIG_ECM_HOST);
appConfig.aosHost = appConfig.aosHost.replace('{protocol}//{hostname}{:port}', APP_CONFIG_ECM_HOST);
}
},
identityHost: {
flags: '-i, --identity-host',
description: "set identityHost's value with APP_CONFIG_IDENTITY_HOST",
set: (appConfig) => {
appConfig.authType = 'OAUTH';
appConfig.identityHost = APP_CONFIG_IDENTITY_HOST;
}
},
oauthHost: {
flags: '-o, --oauth-host',
description: "set oauth2.host's value with APP_CONFIG_OAUTH2_HOST",
set: (appConfig) => {
appConfig.authType = 'OAUTH';
appConfig.oauth2.host = APP_CONFIG_OAUTH2_HOST;
}
},
notification: {
flags: '-n, --notification',
description: "set notificationDefaultDuration's value with <duration> and switch on showNotificationHistory",
set: (appConfig) => {
appConfig.showNotificationHistory = true;
appConfig.notificationDefaultDuration = APP_CONFIG_NOTIFICATION_LAST;
}
}
};
program.version('0.0.1').requiredOption('-c, --config <path>', 'path to the app.config.json to reset its values with env vars');
Object.keys(options).forEach((option) => {
program.option(options[option].flags, options[option].description);
});
program.parse(process.argv);
fs.readFile(program.config, (err, appConfigString) => {
if (err) {
throw err;
}
const appConfig = JSON.parse(appConfigString);
Object.keys(options).forEach((option) => {
if (program[option]) {
options[option].set(appConfig);
}
});
const appConfigReplacedJson = JSON.stringify(appConfig, null, 4);
fs.writeFileSync(program.config, appConfigReplacedJson);
});

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
storage_dir="./storage-state/AdminUserState.json"
rm -rf $storage_dir
# Upload protractor-smartrunner artifact related to this particular job to S3
./scripts/ci/utils/artifact-to-s3.sh -a "$SMART_RUNNER_DIRECTORY" -o "$S3_DBP_FOLDER/protractor-smartrunner-$TRAVIS_JOB_ID.tar.bz2"

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
npx playwright install chromium

View File

@ -1,48 +0,0 @@
#!/usr/bin/env bash
# ---------------------------------------------------------------
# Validating replaced app.config.json
# ---------------------------------------------------------------
app_config_checker(){
APP_CONFIG_FILE_PATH=$1;
echo -n " \_ Validating replaced config file ... ";
$(npm bin)/ajv validate -s ./node_modules/@alfresco/adf-core/app.config.schema.json -d $APP_CONFIG_FILE_PATH --errors=text --verbose || exit 4
if grep -E -q '\$\{[A-Z0-9_]*\}' $APP_CONFIG_FILE_PATH; then
echo -e "\e[31m \_ ERROR: Variables are still present in the app.config.json file. Some of them might not have default value set.\e[0m";
exit 5;
fi
}
FROM=$1;
TO=$2;
PARAMS=$3;
echo "====== Check content UP ====="
./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host "$APP_CONFIG_ECM_HOST" -u "$ADMIN_EMAIL" -p "$ADMIN_PASSWORD" || exit 1
echo "====== Download artifacts ====="
# Download built application artifact from S3
./scripts/ci/utils/artifact-from-s3.sh -a "$FROM" -o "$TO"
APP_CONFIG_FILE_PATH="$TO/app.config.json"
EXTRA_ENV_SETTINGS=""
# Replace variables in app.config.json
envsub $EXTRA_ENV_SETTINGS --all $APP_CONFIG_FILE_PATH $APP_CONFIG_FILE_PATH || exit 1
app_config_checker $APP_CONFIG_FILE_PATH
# Download protractor-smartrunner artifact related to this particular job from S3, if exists
./scripts/ci/utils/artifact-from-s3.sh -a "$S3_DBP_FOLDER/protractor-smartrunner-$TRAVIS_JOB_ID.tar.bz2" -o "$SMART_RUNNER_DIRECTORY"
echo "====== Update webdriver-manager ====="
if [ "$CI" = "true" ]; then
export chrome=$(google-chrome --product-version)
echo "Updating wedriver-manager with chromedriver: $chrome."
webdriver-manager update --gecko=false --versions.chrome=$chrome
else
echo "Updating wedriver-manager with latest chromedriver, be sure to use evergreen Chrome."
webdriver-manager update --gecko=false
fi

View File

@ -1,42 +0,0 @@
#!/usr/bin/env bash
PARENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
# Build and test options -----------------------------------------------------------------------
export BUILD_OPTS="--configuration=production,e2e"
export TEST_OPTS=""
export E2E_PROTRACTOR_OPTS=""
export E2E_TSCONFIG="tsconfig.e2e.json"
# Commit settings for ADF linking -----------------------------------------------------
export HEAD_COMMIT_HASH=${TRAVIS_PULL_REQUEST_SHA:-${TRAVIS_COMMIT}}
export COMMIT_MESSAGE=`git log --format=%B -n 1 $HEAD_COMMIT_HASH`
# Settings for Angular builder --------------------------------------------------------
export NODE_OPTIONS="--max_old_space_size=30000"
# Settings for protractor-smartrunner -------------------------------------------------
export GIT_HASH=`git rev-parse HEAD`
export SMART_RUNNER_DIRECTORY=".protractor-smartrunner"
# Settings for Nx ---------------------------------------------------------------------
export BASE_HASH="$(git describe --tags `git rev-list --tags --max-count=1`)"
export HEAD_HASH="HEAD"
# Settings for S3 caching -------------------------------------------------------------
pip install --user awscli
S3_DBP_PATH="s3://alfresco-travis-builds/aca"
if [ "${TRAVIS_EVENT_TYPE}" == "push" ]; then
export S3_DBP_ROOT_FOLDER="$S3_DBP_PATH/$TRAVIS_BRANCH"
elif [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
export S3_DBP_ROOT_FOLDER="$S3_DBP_PATH/$TRAVIS_PULL_REQUEST"
export BASE_HASH="origin/$TRAVIS_BRANCH"
source $PARENT_DIR/partials/_adf-linking.sh
elif [ "${TRAVIS_EVENT_TYPE}" == "cron" ]; then
export S3_DBP_ROOT_FOLDER="$S3_DBP_PATH/cron"
else
export S3_DBP_ROOT_FOLDER="$S3_DBP_PATH/api"
fi
export S3_DBP_FOLDER="$S3_DBP_ROOT_FOLDER/$TRAVIS_BUILD_ID"
echo "BASE_HASH: $BASE_HASH"
echo "S3 DBP root folder: $S3_DBP_ROOT_FOLDER"
echo "S3 DBP destination: $S3_DBP_FOLDER"

View File

@ -1,44 +0,0 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
show_help() {
echo "Usage: affected-filtered-project.sh"
echo ""
echo "-target Project target"
echo "-tag Filter project with tag"
echo "-name Filter project with name"
echo "-test-runner Test runner to use (playwright or protractor)"
}
project_target(){
PROJECT_TARGET=$1
}
target_options(){
OPTIONS="$1"
}
test_runner(){
TEST_RUNNER=$1
}
while [[ $1 == -* ]]; do
case "$1" in
-target) project_target $2; shift 2;;
-options) target_options $2; shift 2;;
-test-runner) test_runner $2; shift 2;;
-*) echo "invalid option: $1" 1>&2; show_help; exit 0;;
esac
done
./node_modules/.bin/tsc -p "./e2e/$E2E_TSCONFIG" || exit 1;
./node_modules/.bin/http-server -c-1 $CONTENT_CE_DIST_PATH -p 4200 > /dev/null &\
if [ "$TEST_RUNNER" == "playwright" ]; then
echo "Running playwright tests with options $OPTIONS"
npx playwright test --config $OPTIONS
else
echo "Running protractor tests with options $OPTIONS"
echo "./node_modules/.bin/protractor \"./protractor.conf.js\" $OPTIONS || exit 1"
./node_modules/.bin/protractor "./protractor.conf.js" $OPTIONS $E2E_PROTRACTOR_OPTS || exit 1
fi

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
BRANCH=`echo $COMMIT_MESSAGE | grep -o "\[link-adf\:[^]]*\]" | sed -e 's#\[link-adf:##g' | sed -e 's#\]##g'`
echo -e "\e[31mPRs are not mergeable with conditional build. This build was run with custom ADF branch: $BRANCH \e[0m"
exit 1

View File

@ -1,83 +0,0 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR=${DIR}/../../..
DIST_DIR=${ROOT_DIR}/dist/@alfresco
PROJECTS_DIR=${ROOT_DIR}/projects
DRY_RUN=""
if [ "$PUBLISH_PROJECTS" = "false" ]; then
DRY_RUN=true
echo "PUBLISH_PROJECTS is set to false, run in dry mode"
fi
VERSION_IN_PACKAGE_JSON=`node -p "require('$ROOT_DIR/package.json')".version;`;
if [[ $TRAVIS_BRANCH =~ ^master.*?$ ]] ; then
NEW_LIBRARY_VERSION=VERSION_IN_PACKAGE_JSON
else
NEW_LIBRARY_VERSION="${VERSION_IN_PACKAGE_JSON}-${TRAVIS_BUILD_NUMBER}"
fi
if [[ $TRAVIS_BRANCH =~ ^master(-patch.*)?$ ]]
then
# Pre-release versions
if [[ $VERSION_IN_PACKAGE_JSON =~ ^[0-9]*\.[0-9]*\.[0-9]*-A\.[0-9]*$ ]];
then
TAG_NPM=next
# Stable major versions
else
TAG_NPM=latest
fi
fi
if [[ $TRAVIS_BRANCH =~ ^develop(-patch.*)?$ ]]
then
TAG_NPM=alpha
fi
echo -e "Branch is '$TRAVIS_BRANCH', therefore publish with '$TAG_NPM' tag\n"
PROJECTS=(
'aca-shared'
'aca-folder-rules'
'adf-office-services-ext'
'aca-about'
'aca-preview'
'aca-viewer'
'aca-content'
);
for PROJECT in "${PROJECTS[@]}"
do
echo "Update ${PROJECT} version to ${NEW_LIBRARY_VERSION}"
cd $PROJECTS_DIR/${PROJECT}
npm version ${NEW_LIBRARY_VERSION};
done
echo -e "\n\nBuild projects"
cd ${ROOT_DIR}
npm run build-libs
for PROJECT in "${PROJECTS[@]}"
do
cd $DIST_DIR/${PROJECT}
if [ "$DRY_RUN" = "true" ] ; then
echo -e "Publish with dry mode for project: $PROJECT\n"
echo -e "npm publish --dry-run --tag $TAG_NPM \n"
npm publish --dry-run --tag $TAG_NPM
else
echo -e "======== Publishing project: $PROJECT ========\n"
echo -e "npm publish --tag $TAG_NPM\n"
echo 'strict-ssl=true' >> .npmrc
echo 'registry=https://${NPM_REGISTRY_ADDRESS}' >> .npmrc
echo '//${NPM_REGISTRY_ADDRESS}/:_authToken="${NPM_REGISTRY_TOKEN}"' >> .npmrc
npm publish --tag $TAG_NPM
fi
done

View File

@ -1,22 +0,0 @@
# Note no #!/bin/sh as this should not spawn
# an extra shell, since this partial shell script
# is supposed to be invoked as part of another.
# ---------------------------------------------------------------
# ADF linking
# ---------------------------------------------------------------
if [[ $COMMIT_MESSAGE == *"[link-adf:"* ]]; then
export BUILD_OPTS="--configuration=adfprod,e2e"
export TEST_OPTS="--configuration=adfprod"
export E2E_PROTRACTOR_OPTS="--with-local-adf"
export E2E_TSCONFIG="tsconfig.e2e.adf.json"
BRANCH=`echo $COMMIT_MESSAGE | grep -o "\[link-adf\:[^]]*\]" | sed -e 's#\[link-adf:##g' | sed -e 's#\]##g'`
echo "Checking out ADF's branch: ${BRANCH}" && \
git clone https://github.com/Alfresco/alfresco-ng2-components.git --depth=1 --branch ${BRANCH} ../alfresco-ng2-components
# ADF theming needs it the styling
CWD=`pwd`
cd ../alfresco-ng2-components
npm install @angular/material
cd $CWD
else
echo -e "\e[32mUsing ADF from installed node_modules.\e[0m"
fi ;

View File

@ -1,31 +0,0 @@
#!/usr/bin/env bash
show_help() {
echo "Usage: artifact-from-s3.sh <options>"
echo ""
echo "-a or --artifact [mandatory]: path to the s3 artifact (tar.bz2) to download and extract"
echo "-o or --output [mandatory]: directory to extract the archive to"
}
while [[ $1 == -* ]]; do
case "$1" in
-h|--help|-\?) show_help; exit 0;;
-a|--artifact) ARTIFACT=$2; shift 2;;
-o|--output) OUTPUT=$2; shift 2;;
-*) shift;;
esac
done
if [ "${ARTIFACT}" == "" ] || [ "${OUTPUT}" == "" ]
then
show_help;
exit 1
fi
test ! -d $OUTPUT && mkdir -p $OUTPUT
aws s3 cp $ARTIFACT ./s3-artifact.tmp
echo 'artifact download done'
tar -xvf ./s3-artifact.tmp -C $OUTPUT >&/dev/null
echo 'tar the artifact done'
rm ./s3-artifact.tmp
echo 'remove tmp file'

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
show_help() {
echo "Usage: artifact-to-s3.sh <options>"
echo ""
echo "-a or --artifact [mandatory]: path to the artifact to archieve (tar.bz2) and upload (like ./dist)"
echo "-o or --output [mandatory]: the S3 object to copy it to, like: s3://bucket-name/folder/whatever.tar.bz2"
}
while [[ $1 == -* ]]; do
case "$1" in
-h|--help|-\?) show_help; exit 0;;
-a|--artifact) ARTIFACT=$2; shift 2;;
-o|--output) OUTPUT=$2; shift 2;;
-*) shift;;
esac
done
if [ "${ARTIFACT}" == "" ] || [ "${OUTPUT}" == "" ]
then
show_help;
exit 1
fi
tar cvfj ./s3-artifact.tmp -C $ARTIFACT `ls $ARTIFACT`
aws s3 cp ./s3-artifact.tmp $OUTPUT
rm ./s3-artifact.tmp

View File

@ -1,9 +0,0 @@
#!/usr/bin/env bash
if [[ $TRAVIS_BRANCH == "master" ]]; then
TAG_VERSION=$(grep -m1 version package.json | awk '{ print $2 }' | sed 's/[", ]//g')
else
TAG_VERSION=$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER
fi;
echo $TAG_VERSION;

View File

@ -1,14 +0,0 @@
#!/bin/bash
if [[ $TRAVIS_BRANCH == "master" ]]; then
VERSION=$(grep -m1 version package.json | awk '{ print $2 }' | sed 's/[", ]//g')
fi;
echo "git tag -a ${VERSION} -m ${VERSION}"
git config --local user.name "alfresco-build"
git config --local user.email "build@alfresco.com"
git tag -a ${VERSION} -m "${VERSION} [ci skip] "
git remote rm origin
GITHUB_REPO=https://$GITHUB_TOKEN:x-oauth-basic@github.com/Alfresco/alfresco-content-app.git
git remote add origin $GITHUB_REPO
git push origin --tags

View File

@ -1,62 +0,0 @@
#!/bin/sh -f
# Trigger a new Travis-CI job.
# Usage:
# trigger-travis.sh [--branch BRANCH] GITHUBID GITHUBPROJECT TRAVIS_API_TOKEN [MESSAGE]
# For example:
# trigger-travis.sh typetools checker-framework `cat ~/private/.travis-access-token` "Trigger for testing"
if [ "$#" -lt 3 ] || [ "$#" -ge 7 ]; then
echo "Wrong number of arguments $# to trigger-travis.sh; run like:"
echo " trigger-travis.sh [--branch BRANCH] GITHUBID GITHUBPROJECT TRAVIS_API_TOKEN [MESSAGE]" >&2
exit 1
fi
if [ "$1" = "--branch" ] ; then
shift
BRANCH="$1"
shift
else
BRANCH=master
fi
USER=$1
REPO=$2
TOKEN=$3
if [ $# -eq 4 ] ; then
MESSAGE=",\"message\": \"$4\""
elif [ -n "$TRAVIS_REPO_SLUG" ] ; then
MESSAGE=",\"message\": \"Triggered by ACA upstream [affected:content-ee,content-ee-apa]\""
else
MESSAGE=""
fi
## For debugging:
# echo "USER=$USER"
# echo "REPO=$REPO"
# echo "TOKEN=$TOKEN"
# echo "MESSAGE=$MESSAGE"
body="{
\"request\": {
\"branch\":\"$BRANCH\"
$MESSAGE
}}"
# "%2F" creates a literal "/" in the URL, that is not interpreted as a
# segment or directory separator.
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token ${TOKEN}" \
-d "$body" \
https://api.travis-ci.com/repo/${USER}%2F${REPO}/requests \
| tee /tmp/travis-request-output.$$.txt
if grep -q '"@type": "error"' /tmp/travis-request-output.$$.txt; then
exit 1
fi
if grep -q 'access denied' /tmp/travis-request-output.$$.txt; then
exit 1
fi