forked from gchq/sleeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
673afeb
commit 82d483c
Showing
2 changed files
with
60 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
|
||
# | ||
# Copyright 2022-2023 Crown Copyright | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
set -e | ||
unset CDPATH | ||
|
||
THIS_DIR=$(cd "$(dirname "$0")" && pwd) | ||
SCRIPTS_DIR=$(cd "$THIS_DIR" && cd ../.. && pwd) | ||
MAVEN_DIR=$(cd "$SCRIPTS_DIR" && cd ../java && pwd) | ||
|
||
if [ "$#" -ne 4 ]; then | ||
echo "Usage: $0 <repo-path> <private-key-pem-file> <app-id> <installation-id>" | ||
exit 1 | ||
fi | ||
|
||
REPO_PATH=$1 | ||
PRIVATE_KEY=$2 | ||
APP_ID=$3 | ||
INSTALLATION_ID=$4 | ||
|
||
pushd "$MAVEN_DIR" | ||
echo "Compiling build module..." | ||
mvn compile -Pquick -q -pl build -am | ||
|
||
pushd build | ||
echo "Generating access token..." | ||
ACCESS_TOKEN_FILE=$(mktemp) | ||
mvn exec:java -q \ | ||
-Dexec.mainClass="sleeper.build.github.app.GenerateGitHubAppInstallationAccessToken" \ | ||
-Dexec.args="$PRIVATE_KEY $APP_ID $INSTALLATION_ID $ACCESS_TOKEN_FILE" | ||
popd | ||
|
||
ACCESS_TOKEN=$(<"$ACCESS_TOKEN_FILE") | ||
git remote set-url origin "https://x-access-token:$ACCESS_TOKEN@github.com/$REPO_PATH.git" | ||
git switch --discard-changes -C main origin/main | ||
git pull | ||
git merge develop | ||
git push | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters