mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACS-4632] Add GH workflow to trigger ACA upstream (#2992)
* [ACS-4632] Add GH workflow to trigger ACA upstream * [ACS-4632] Bump node version and switch to npm cache
This commit is contained in:
parent
a6e6f08df0
commit
ffb9c13b93
39
.github/workflows/aca-upstream.yml
vendored
Normal file
39
.github/workflows/aca-upstream.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: "ACA upstream"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
repo_to_update:
|
||||||
|
description: Repository to update
|
||||||
|
type: choice
|
||||||
|
required: true
|
||||||
|
options:
|
||||||
|
- alfresco-applications
|
||||||
|
- alfresco-apps
|
||||||
|
default: alfresco-applications
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||||
|
TRAVIS_COMMIT: ${{ github.sha }}
|
||||||
|
TRAVIS_BUILD_NUMBER: ${{ github.run_id }}
|
||||||
|
NODE_OPTIONS: "--max-old-space-size=5120"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
trigger_aca_upstream:
|
||||||
|
name: Trigger ACA upstream
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: install NPM
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
cache: 'npm'
|
||||||
|
- name: Trigger upstream
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
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 }}
|
@ -206,8 +206,8 @@ jobs:
|
|||||||
|
|
||||||
- stage: Trigger DW
|
- stage: Trigger DW
|
||||||
script:
|
script:
|
||||||
- ./scripts/trigger-travis.sh --branch $TRAVIS_BRANCH Alfresco alfresco-apps $TRAVIS_API_TOKEN
|
- ./scripts/trigger-travis.sh --branch $TRAVIS_BRANCH Alfresco alfresco-applications $TRAVIS_API_TOKEN
|
||||||
- ./scripts/travis/update/update-project.sh -p $TRAVIS_BUILD_NUMBER -t $GITHUB_TOKEN -v alpha -c $TRAVIS_COMMIT
|
- ./scripts/travis/update/update-project.sh -p $TRAVIS_BUILD_NUMBER -t $GITHUB_TOKEN -v alpha -c $TRAVIS_COMMIT -r alfresco-applications
|
||||||
|
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
|
@ -17,8 +17,10 @@ show_help() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "-t or --token: Github ouath token"
|
echo "-t or --token: Github ouath token"
|
||||||
echo "-p or --pr: Originating ACA PR number"
|
echo "-p or --pr: Originating ACA PR number"
|
||||||
echo "-v or --version version to update"
|
echo "-v or --version: version to update"
|
||||||
|
echo "-c or --commit: commit"
|
||||||
echo "-d or --dry-run: The script won't execute critical operation, just simulate them"
|
echo "-d or --dry-run: The script won't execute critical operation, just simulate them"
|
||||||
|
echo "-r or --repo: Repository to update"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_token() {
|
set_token() {
|
||||||
@ -38,15 +40,18 @@ set_commit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_dryrun() {
|
set_dryrun() {
|
||||||
|
|
||||||
DRY_RUN="true"
|
DRY_RUN="true"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_repo() {
|
||||||
|
REPO=$1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
update_dependency() {
|
update_dependency() {
|
||||||
PKG=$1
|
PKG=$1
|
||||||
PKG_VERSION=$(npm view $PKG@$VERSION version)
|
PKG_VERSION=$(npm view $PKG@$VERSION version)
|
||||||
echo "Update $PKG to $PKG_VERSION in $NAME_REPO"
|
echo "Update $PKG to $PKG_VERSION in $REPO"
|
||||||
|
|
||||||
for i in $(find . ! -path "*/node_modules/*" -name "package-lock.json" | xargs grep -l $PKG); do
|
for i in $(find . ! -path "*/node_modules/*" -name "package-lock.json" | xargs grep -l $PKG); do
|
||||||
directory=$(dirname $i)
|
directory=$(dirname $i)
|
||||||
@ -59,11 +64,10 @@ update_dependency() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
NAME_REPO=$1
|
|
||||||
PKG_VERSION=$(npm view $PKG@$VERSION version)
|
PKG_VERSION=$(npm view $PKG@$VERSION version)
|
||||||
echo "Update dependencies $NAME_REPO"
|
echo "Update dependencies $REPO"
|
||||||
|
|
||||||
git clone https://$TOKEN@github.com/Alfresco/$NAME_REPO.git $TEMP_GENERATOR_DIR
|
git clone https://$TOKEN@github.com/Alfresco/$REPO.git $TEMP_GENERATOR_DIR
|
||||||
cd $TEMP_GENERATOR_DIR
|
cd $TEMP_GENERATOR_DIR
|
||||||
|
|
||||||
git fetch
|
git fetch
|
||||||
@ -91,7 +95,7 @@ update() {
|
|||||||
git push --force origin $BRANCH_TO_CREATE
|
git push --force origin $BRANCH_TO_CREATE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
node $BUILD_PIPELINE_DIR/pr-creator.js --token=$TOKEN --title="Update branch for ACA ${PKG_VERSION} [ci:force]" --head=$BRANCH_TO_CREATE --repo=$NAME_REPO --commit=$COMMIT
|
node $BUILD_PIPELINE_DIR/pr-creator.js --token=$TOKEN --title="Update branch for ACA ${PKG_VERSION} [ci:force]" --head=$BRANCH_TO_CREATE --repo=$REPO --commit=$COMMIT
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
rm -rf $TEMP_GENERATOR_DIR
|
rm -rf $TEMP_GENERATOR_DIR
|
||||||
@ -105,6 +109,7 @@ while [[ $1 == -* ]]; do
|
|||||||
-v|--version) version $2; shift 2;;
|
-v|--version) version $2; shift 2;;
|
||||||
-c|--commit) set_commit $2; shift 2;;
|
-c|--commit) set_commit $2; shift 2;;
|
||||||
-d|--dry-run) set_dryrun $2; shift; shift;;
|
-d|--dry-run) set_dryrun $2; shift; shift;;
|
||||||
|
-r|--repo) set_repo $2; shift; shift;;
|
||||||
-*) echo "invalid option: $1" 1>&2; show_help; exit 1;;
|
-*) echo "invalid option: $1" 1>&2; show_help; exit 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -113,20 +118,20 @@ cd "$REPO_DIR"
|
|||||||
|
|
||||||
if [[ (-z "$TOKEN") || (-z "$VERSION") ]]
|
if [[ (-z "$TOKEN") || (-z "$VERSION") ]]
|
||||||
then
|
then
|
||||||
echo "Each of 'branch name' (-b) token (-t) and pr number (-p) have to be set. See -help."
|
echo "Each of 'branch name' (-b) token (-t) pr number (-p) and repo (-r) have to be set. See -help."
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf $TEMP_GENERATOR_DIR
|
rm -rf $TEMP_GENERATOR_DIR
|
||||||
|
|
||||||
isSameACASha=$(node $BUILD_PIPELINE_DIR/aca-same-commit-verify.js --token=$TOKEN --head=$BRANCH_TO_CREATE --repo=$NAME_REPO --commit=$COMMIT )
|
isSameACASha=$(node $BUILD_PIPELINE_DIR/aca-same-commit-verify.js --token=$TOKEN --head=$BRANCH_TO_CREATE --repo=$REPO --commit=$COMMIT )
|
||||||
if [ "$isSameACASha" = 'true' ]; then
|
if [ "$isSameACASha" = 'true' ]; then
|
||||||
echo 'ACA sha is the same. No need to create another pr'
|
echo 'ACA sha is the same. No need to create another pr'
|
||||||
else
|
else
|
||||||
if [ "$DRY_RUN" = "false" ]; then
|
if [ "$DRY_RUN" = "false" ]; then
|
||||||
update "alfresco-apps"
|
update $REPO
|
||||||
else
|
else
|
||||||
echo "[dry-run] it would have update repos: 'alfresco-apps'"
|
echo "[dry-run] it would have update $REPO repo"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user