Merge pull request #2682 from crazyserver/MOBILE-3708
MOBILE-3708 github: Add mirroring action
This commit is contained in:
		
						commit
						0ee496f890
					
				
							
								
								
									
										65
									
								
								.github/scripts/functions.sh
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								.github/scripts/functions.sh
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,65 @@ | ||||
| #!/bin/bash | ||||
| 
 | ||||
| function check_success_exit { | ||||
|     if [ $? -ne 0 ]; then | ||||
|         print_error "$1" | ||||
|         exit 1 | ||||
|     elif [ "$#" -gt 1 ]; then | ||||
|         print_ok "$2" | ||||
|     fi | ||||
| } | ||||
| 
 | ||||
| function check_success { | ||||
|     if [ $? -ne 0 ]; then | ||||
|         print_error "$1" | ||||
|     elif [ "$#" -gt 1 ]; then | ||||
|         print_ok "$2" | ||||
|     fi | ||||
| } | ||||
| 
 | ||||
| function print_success { | ||||
|     if [ $? -ne 0 ]; then | ||||
|         print_message "$1" | ||||
|         $3=0 | ||||
|     else | ||||
|         print_ok "$2" | ||||
|     fi | ||||
| } | ||||
| 
 | ||||
| function print_error { | ||||
|     echo "  ERROR:  $1" | ||||
| } | ||||
| 
 | ||||
| function print_ok { | ||||
|     echo "     OK:  $1" | ||||
|     echo | ||||
| } | ||||
| 
 | ||||
| function print_message { | ||||
|     echo "--------  $1" | ||||
|     echo | ||||
| } | ||||
| 
 | ||||
| function print_title { | ||||
|     stepnumber=$(($stepnumber + 1)) | ||||
|     echo | ||||
|     echo "$stepnumber $1" | ||||
|     echo '==================' | ||||
| } | ||||
| 
 | ||||
| function telegram_notify { | ||||
|     if [ ! -z $TELEGRAM_APIKEY ] && [ ! -z $TELEGRAM_CHATID ] ; then | ||||
|         MESSAGE="Travis error: $1%0ABranch: $TRAVIS_BRANCH%0ARepo: $TRAVIS_REPO_SLUG" | ||||
|         URL="https://api.telegram.org/bot$TELEGRAM_APIKEY/sendMessage" | ||||
| 
 | ||||
|         curl -s -X POST $URL -d chat_id=$TELEGRAM_CHATID -d text="$MESSAGE" | ||||
|     fi | ||||
| } | ||||
| 
 | ||||
| function notify_on_error_exit { | ||||
|     if [ $? -ne 0 ]; then | ||||
|         print_error "$1" | ||||
|         telegram_notify "$1" | ||||
|         exit 1 | ||||
|     fi | ||||
| } | ||||
							
								
								
									
										14
									
								
								.github/scripts/mirror.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								.github/scripts/mirror.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @ -0,0 +1,14 @@ | ||||
| #!/bin/bash | ||||
| source "/.github/scripts/functions.sh" | ||||
| BRANCH=${GITHUB_REF##*/} | ||||
| 
 | ||||
| if [ -z $GIT_TOKEN ] || [ -z $BRANCH ] || [ $GITHUB_REPOSITORY != 'moodlehq/moodleapp' ]; then | ||||
|     print_error "Env vars not correctly defined" | ||||
|     exit 1 | ||||
| fi | ||||
| 
 | ||||
| git remote add mirror https://$GIT_TOKEN@github.com/moodlemobile/moodleapp.git | ||||
| git push -f mirror HEAD:$BRANCH | ||||
| notify_on_error_exit "MIRROR: Unsuccessful mirror, stopping..." | ||||
| git push -f mirror --tags | ||||
| notify_on_error_exit "MIRROR: Unsuccessful mirror tags, stopping..." | ||||
							
								
								
									
										20
									
								
								.github/workflows/mirror.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								.github/workflows/mirror.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| name: Mirror | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: [ master, integration, ionic5 ] | ||||
| 
 | ||||
| jobs: | ||||
|   mirror: | ||||
|     if: github.repository == 'moodlehq/moodleapp' | ||||
|     runs-on: ubuntu-latest | ||||
| 
 | ||||
|     steps: | ||||
|     - uses: actions/checkout@v2 | ||||
|       with: | ||||
|         persist-credentials: false | ||||
|         fetch-depth: 0 | ||||
|     - name: Mirror the branch and tags | ||||
|       env: | ||||
|         GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | ||||
|       run: ./.github/scripts/mirror.sh | ||||
							
								
								
									
										2
									
								
								.github/workflows/testing.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/testing.yml
									
									
									
									
										vendored
									
									
								
							| @ -3,7 +3,7 @@ name: Testing | ||||
| on: [push, pull_request] | ||||
| 
 | ||||
| jobs: | ||||
|   build: | ||||
|   test: | ||||
| 
 | ||||
|     runs-on: ubuntu-latest | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user