cache based on branch name
parent
15f18977f9
commit
99fd44f598
|
|
@ -222,9 +222,11 @@ const core = __importStar(__webpack_require__(42186));
|
|||
const zlib = __importStar(__webpack_require__(78761));
|
||||
class AWS {
|
||||
static runBuildJob(buildParameters, baseImage) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const buildUid = nanoid_1.nanoid();
|
||||
const branchName = (_a = process.env.GITHUB_REF) === null || _a === void 0 ? void 0 : _a.split('/').reverse()[0];
|
||||
core.info('starting part 1/4 (clone from github and restore cache)');
|
||||
yield this.run(buildUid, buildParameters.awsStackName, 'alpine/git', ['/bin/sh'], [
|
||||
'-c',
|
||||
|
|
@ -236,11 +238,11 @@ class AWS {
|
|||
git clone https://${process.env.GITHUB_TOKEN}@github.com/${process.env.GITHUB_REPOSITORY}.git ${buildUid}/repo;
|
||||
git clone https://${process.env.GITHUB_TOKEN}@github.com/game-ci/unity-builder.git ${buildUid}/builder;
|
||||
|
||||
if [ ! -d "cache" ]; then
|
||||
mkdir "cache"
|
||||
if [ ! -d "cache/${branchName}" ]; then
|
||||
mkdir "cache/${branchName}"
|
||||
fi
|
||||
|
||||
cd cache
|
||||
cd ./cache/${branchName}
|
||||
ls
|
||||
|
||||
echo ''
|
||||
|
|
@ -249,7 +251,7 @@ class AWS {
|
|||
echo $latest
|
||||
if [ -f $latest ]; then
|
||||
echo "Cache exists"
|
||||
unzip $latest ../${buildUid}/repo/Library/.
|
||||
unzip $latest ../../${buildUid}/repo/Library/.
|
||||
else
|
||||
echo "Cache does not exist"
|
||||
fi
|
||||
|
|
@ -369,7 +371,7 @@ class AWS {
|
|||
`
|
||||
apk update;
|
||||
apk add zip
|
||||
zip -r ./${buildUid}/repo/Library/* ./cache/lib-${buildUid}.zip
|
||||
zip -r ./${buildUid}/repo/Library/* ./cache/${branchName}/lib-${buildUid}.zip
|
||||
zip -r ./${buildUid}/repo/build/* ./build-${buildUid}.zip
|
||||
ls
|
||||
`,
|
||||
|
|
@ -389,7 +391,7 @@ class AWS {
|
|||
'-c',
|
||||
`
|
||||
aws s3 cp ./build-${buildUid}.zip s3://game-ci-storage/${buildUid}.zip
|
||||
aws s3 cp ./cache/lib-${buildUid}.zip s3://game-ci-storage/lib-${buildUid}.zip
|
||||
aws s3 cp ./cache/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/lib-${buildUid}.zip
|
||||
rm -r ${buildUid}
|
||||
ls
|
||||
`,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -8,7 +8,7 @@ class AWS {
|
|||
static async runBuildJob(buildParameters, baseImage) {
|
||||
try {
|
||||
const buildUid = nanoid();
|
||||
|
||||
const branchName = process.env.GITHUB_REF?.split('/').reverse()[0];
|
||||
core.info('starting part 1/4 (clone from github and restore cache)');
|
||||
await this.run(
|
||||
buildUid,
|
||||
|
|
@ -25,11 +25,11 @@ class AWS {
|
|||
git clone https://${process.env.GITHUB_TOKEN}@github.com/${process.env.GITHUB_REPOSITORY}.git ${buildUid}/repo;
|
||||
git clone https://${process.env.GITHUB_TOKEN}@github.com/game-ci/unity-builder.git ${buildUid}/builder;
|
||||
|
||||
if [ ! -d "cache" ]; then
|
||||
mkdir "cache"
|
||||
if [ ! -d "cache/${branchName}" ]; then
|
||||
mkdir "cache/${branchName}"
|
||||
fi
|
||||
|
||||
cd cache
|
||||
cd ./cache/${branchName}
|
||||
ls
|
||||
|
||||
echo ''
|
||||
|
|
@ -38,7 +38,7 @@ class AWS {
|
|||
echo $latest
|
||||
if [ -f $latest ]; then
|
||||
echo "Cache exists"
|
||||
unzip $latest ../${buildUid}/repo/Library/.
|
||||
unzip $latest ../../${buildUid}/repo/Library/.
|
||||
else
|
||||
echo "Cache does not exist"
|
||||
fi
|
||||
|
|
@ -179,7 +179,7 @@ class AWS {
|
|||
`
|
||||
apk update;
|
||||
apk add zip
|
||||
zip -r ./${buildUid}/repo/Library/* ./cache/lib-${buildUid}.zip
|
||||
zip -r ./${buildUid}/repo/Library/* ./cache/${branchName}/lib-${buildUid}.zip
|
||||
zip -r ./${buildUid}/repo/build/* ./build-${buildUid}.zip
|
||||
ls
|
||||
`,
|
||||
|
|
@ -210,7 +210,7 @@ class AWS {
|
|||
'-c',
|
||||
`
|
||||
aws s3 cp ./build-${buildUid}.zip s3://game-ci-storage/${buildUid}.zip
|
||||
aws s3 cp ./cache/lib-${buildUid}.zip s3://game-ci-storage/lib-${buildUid}.zip
|
||||
aws s3 cp ./cache/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/lib-${buildUid}.zip
|
||||
rm -r ${buildUid}
|
||||
ls
|
||||
`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue