Skip to content

Commit

Permalink
feat(deps)(automation): dynamic sync deps (#318)
Browse files Browse the repository at this point in the history
This PR introduces a specific task in order to automate s3 sync for our
custom dependencies.
This script is then used by the pipeline responsible to keep our deps
synced
  • Loading branch information
datYori authored Jan 12, 2024
1 parent c0ae9a4 commit e4df88f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/sync-deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
run: |
M2_HOME=/home/sbtuser/.m2/repository
aws s3 sync $M2_HOME s3://$BUCKET/maven --exclude '*' --include '**kiama**'
aws s3 sync $M2_HOME s3://$BUCKET/maven --exclude '*' --include '**jackson**'
aws s3 sync $M2_HOME s3://$BUCKET/maven --exclude '*' --include '**scala-logging**'
aws s3 sync $M2_HOME s3://$BUCKET/maven --exclude '*' --include '**jwt-core**'
cd deps/others
sbt createS3SyncScript
export M2_HOME BUCKET
./s3-sync-deps.sh
3 changes: 2 additions & 1 deletion deps/others/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.jar
manifest.txt
manifest.txt
s3-sync-deps.sh
23 changes: 23 additions & 0 deletions deps/others/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,28 @@ patchDependencies := {
}


val createS3SyncScript = taskKey[Unit]("Create a bash script for syncing dependencies to S3")

val scriptFile = "s3-sync-deps.sh"

createS3SyncScript := {
val dependencies = libraryDependencies.value

val writer = new BufferedWriter(new FileWriter(scriptFile))

try {
writer.write("#!/bin/bash\n\n")
dependencies.foreach { dep =>
writer.write(s"aws s3 sync $$M2_HOME s3://$$BUCKET/maven --exclude '*' --include '**${dep.name}**'\n")
}
} finally {
// Always close the writer to release resources
writer.close()
}

// Make the script executable
new File(scriptFile).setExecutable(true)

// Notify that the task is completed
println(s"Bash script created: $scriptFile")
}

0 comments on commit e4df88f

Please sign in to comment.