8181 BACKEND_BASE_URL : https://ktorbase.opencpms.io/
8282 BACKEND_PORT : 443
8383 run : ./gradlew integrationTest
84-
85- bitbucket-build-and-test :
86- needs : github-build-and-test
87- runs-on : ubuntu-latest
88- steps :
89- - uses : actions/cache@v2
90- with :
91- path : |
92- ~/.gradle/caches
93- ~/.gradle/wrapper
94- key : ${{ runner.os }}-gradle-example-ktorbase-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
95- restore-keys : |
96- ${{ runner.os }}-gradle-example-ktorbase-
97-
98- # ktor prevents compile-time 11, see: https://youtrack.jetbrains.com/issue/KTOR-619
99- - name : Set up JDK 8
100- uses : actions/setup-java@v2
101- with :
102- java-version : ' 8'
103- distribution : ' adopt'
104-
105- - name : Install SSH key
106- uses : shimataro/ssh-key-action@v2
107- with :
108- name : id_rsa
109- key : ${{ secrets.BITBUCKET_SSH_KEY }}
110- known_hosts : ${{ secrets.BITBUCKET_KNOWN_HOSTS }}
111-
112- - name : Clone from Bitbucket
113- run : >
114- git clone [email protected] :linked-planet/com.linked-planet.ktor-bitbucket-example.git /tmp/com.linked-planet.ktor-bitbucket-example 115-
116- - name : Update
117- run : >
118- BRANCH=${GITHUB_REF#refs/heads/};
119- curl -O -s "https://raw.githubusercontent.com/linked-planet/ktorbase/$BRANCH/update.sh";
120- sh ./update.sh /tmp/com.linked-planet.ktor-bitbucket-example com.linked-planet ktor-example "$BRANCH"
121-
122- - name : Commit and Push to Bitbucket
123- run : |
124- ORIG_DIR=$(pwd);
125- cd /tmp/com.linked-planet.ktor-bitbucket-example;
126- git config --global user.email "${{ secrets.BITBUCKET_USER_MAIL }}";
127- git config --global user.name "${{ secrets.BITBUCKET_USER_NAME }}";
128- git add -A;
129- echo "Identifying changes ...";
130- git status --porcelain;
131- if ! git diff-index --quiet HEAD --; then git commit -m "updated project from Github commit ${GITHUB_SHA} (${GITHUB_REF})" && touch "$ORIG_DIR/run_pipeline"; fi;
132- git push
133-
134- - name : Watch Bitbucket Pipeline
135- run : |
136- if [ ! -f run_pipeline ]; then echo "-> Skip this step as nothing was pushed to Bitbucket" && exit 0; fi
137- cd /tmp/com.linked-planet.ktor-bitbucket-example;
138- BITBUCKET_COMMIT_HASH=$(git log --format="%h" -n 1);
139- echo "Searching Pipeline for commit $BITBUCKET_COMMIT_HASH in Bitbucket ...";
140- sleep 30;
141- BITBUCKET_PIPELINE_RESPONSE=$(curl -s "https://api.bitbucket.org/2.0/repositories/linked-planet/com.linked-planet.ktor-bitbucket-example/commit/$BITBUCKET_COMMIT_HASH/statuses");
142- BITBUCKET_PIPELINE_ERROR=$(echo "$BITBUCKET_PIPELINE_RESPONSE" | jq -r '.error.message');
143- if [[ $BITBUCKET_PIPELINE_ERROR == "Commit not found" ]]; then echo "-> Nothing to commit and therewith no Pipeline run" && exit 0; fi;
144- BITBUCKET_PIPELINE_LINK=$(echo $BITBUCKET_PIPELINE_RESPONSE | jq -r '.values[0].url');
145- echo "Watching Pipeline $BITBUCKET_PIPELINE_LINK in Bitbucket ...";
146- BITBUCKET_PIPELINE_STATE=$(echo $BITBUCKET_PIPELINE_RESPONSE | jq -r '.values[0].state');
147- while [ $BITBUCKET_PIPELINE_STATE = "INPROGRESS" ]; do \
148- echo "Pipeline still running, waiting ..."; \
149- sleep 5;
150- BITBUCKET_PIPELINE_RESPONSE=$(curl -s "https://api.bitbucket.org/2.0/repositories/linked-planet/com.linked-planet.ktor-bitbucket-example/commit/$BITBUCKET_COMMIT_HASH/statuses"); \
151- BITBUCKET_PIPELINE_STATE=$(echo $BITBUCKET_PIPELINE_RESPONSE | jq -r '.values[0].state'); \
152- done;
153- if [[ $BITBUCKET_PIPELINE_STATE == "FAILED" || $BITBUCKET_PIPELINE_STATE == "STOPPED" ]]; then echo "-> Bitbucket Pipeline failed/stopped" && exit 1; fi;
154- if [[ $BITBUCKET_PIPELINE_STATE == "SUCCESSFUL" ]]; then echo "-> Bitbucket Pipeline succedded" && exit 0; fi;
155- echo "-> Unknown Error with Bitbucket Pipeline" && exit 1
0 commit comments