|
1 | 1 | #!/bin/bash |
| 2 | +source "scripts/functions.sh" |
2 | 3 |
|
3 | | -if [ $TRAVIS_EVENT_TYPE == 'cron' ] ; then |
| 4 | +if [ "$TRAVIS_EVENT_TYPE" == 'cron' ] ; then |
4 | 5 | # Tests scripts. |
5 | | - echo 'CRON NOT IMPLEMENTED YET' |
| 6 | + print_error 'CRON NOT IMPLEMENTED YET' |
6 | 7 | else |
7 | | - ./scripts/aot.sh |
| 8 | + if [ -z $GIT_ORG_PRIVATE ] || [ -z $GIT_TOKEN ]; then |
| 9 | + print_error "Env vars not correctly defined" |
| 10 | + exit 1 |
| 11 | + fi |
| 12 | + |
| 13 | + # List first level of installed libraries so we can check the installed versions. |
| 14 | + print_title "NPM packages list" |
| 15 | + npm list --depth=0 |
| 16 | + |
| 17 | + if [ "$TRAVIS_REPO_SLUG" == 'moodlehq/moodleapp' ]; then |
| 18 | + if [ "$TRAVIS_BRANCH" == 'master' ]; then |
| 19 | + print_title "Update langpacks" |
| 20 | + cd scripts |
| 21 | + ./update_lang.sh |
| 22 | + cd .. |
| 23 | + |
| 24 | + print_title "Update generated lang files" |
| 25 | + git remote set-url origin https://$GIT_TOKEN@github.com/$TRAVIS_REPO_SLUG.git |
| 26 | + git fetch -q origin |
| 27 | + git add -A src/assets/lang |
| 28 | + git add */en.json |
| 29 | + git add src/config.json |
| 30 | + git commit -m 'Update lang files [ci skip]' |
| 31 | + |
| 32 | + print_title "Update Licenses" |
| 33 | + npm install -g license-checker |
| 34 | + |
| 35 | + jq --version |
| 36 | + license-checker --json --production --relativeLicensePath > licenses.json |
| 37 | + jq 'del(.[].path)' licenses.json > licenses_old.json |
| 38 | + mv licenses_old.json licenses.json |
| 39 | + licenses=`jq -r 'keys[]' licenses.json` |
| 40 | + echo "{" > licensesurl.json |
| 41 | + first=1 |
| 42 | + for license in $licenses; do |
| 43 | + obj=`jq --arg lic $license '.[$lic]' licenses.json` |
| 44 | + licensePath=`echo $obj | jq -r '.licenseFile'` |
| 45 | + file="" |
| 46 | + if [[ ! -z "$licensePath" ]] || [[ "$licensePath" != "null" ]]; then |
| 47 | + file=$(basename $licensePath) |
| 48 | + if [ $first -eq 1 ] ; then |
| 49 | + first=0 |
| 50 | + echo "\"$license\" : { \"licenseFile\" : \"$file\"}" >> licensesurl.json |
| 51 | + else |
| 52 | + echo ",\"$license\" : { \"licenseFile\" : \"$file\"}" >> licensesurl.json |
| 53 | + fi |
| 54 | + fi |
| 55 | + done |
| 56 | + echo "}" >> licensesurl.json |
| 57 | + |
| 58 | + jq -s '.[0] * .[1]' licenses.json licensesurl.json > licenses_old.json |
| 59 | + mv licenses_old.json licenses.json |
| 60 | + rm licensesurl.json |
| 61 | + |
| 62 | + git add licenses.json |
| 63 | + git commit -m 'Update licenses [ci skip]' |
| 64 | + |
| 65 | + git push origin HEAD:$TRAVIS_BRANCH |
| 66 | + fi |
| 67 | + |
| 68 | + if [ "$TRAVIS_BRANCH" == 'integration' ] || [ "$TRAVIS_BRANCH" == 'master' ] || [ "$TRAVIS_BRANCH" == 'desktop' ] ; then |
| 69 | + print_title "Mirror repository" |
| 70 | + git remote add mirror https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/moodleapp.git |
| 71 | + git fetch -q mirror |
| 72 | + git push -f mirror HEAD:$TRAVIS_BRANCH |
| 73 | + git push mirror --tags |
| 74 | + fi |
| 75 | + elif [ "$TRAVIS_REPO_SLUG" == "$GIT_ORG_PRIVATE/moodleapp" ]; then |
| 76 | + print_title "Run scripts" |
| 77 | + git clone --depth 1 https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/apps-scripts.git ../scripts |
| 78 | + cp ../scripts/build.sh scripts/ |
| 79 | + ./scripts/build.sh |
| 80 | + fi |
8 | 81 | fi |
0 commit comments