From b64aae5893d5fd5563f881b36604f5107dac74d3 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 5 Dec 2023 11:21:16 +0100 Subject: [PATCH] Github workflow added --- .github/workflows/push-release.yaml | 41 +++++++++++++++++++++++ FednKotlin/app/bin/main/fednkotlin/App.kt | 17 +++++++--- 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/push-release.yaml diff --git a/.github/workflows/push-release.yaml b/.github/workflows/push-release.yaml new file mode 100644 index 0000000..102c60a --- /dev/null +++ b/.github/workflows/push-release.yaml @@ -0,0 +1,41 @@ +name: Build on push/release + +on: + workflow_dispatch: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build Docker image + run: | + docker build -t fedn-kotlin /FednKotlin + + - name: Log in to GitHub Docker Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Log in to Harbor Registry + uses: docker/login-action@v3 + with: + registry: harbor.studio.scaleoutplatform.com + username: robot$github-studio + password: ${{ secrets.HARBOR_TOKEN }} + + - name: Tag Docker image + run: | + docker tag fedn-kotlin ghcr.io/scaleoutsystems/android-client:fedn-kotlin + docker tag fedn-kotlin harbor.studio.scaleoutplatform.com/scaleoutstudio/fedn-kotlin:fedn-kotlin + + - name: Push Docker images + run: | + docker push ghcr.io/scaleoutsystems/android-client:fedn-kotlin + docker push harbor.studio.scaleoutplatform.com/scaleoutstudio/fedn-kotlin:fedn-kotlin diff --git a/FednKotlin/app/bin/main/fednkotlin/App.kt b/FednKotlin/app/bin/main/fednkotlin/App.kt index 9409875..721582c 100644 --- a/FednKotlin/app/bin/main/fednkotlin/App.kt +++ b/FednKotlin/app/bin/main/fednkotlin/App.kt @@ -5,6 +5,7 @@ package fednkotlin import com.example.fedn_client.FednClient import com.example.fedn_client.IFednClient +import java.util.UUID import kotlinx.coroutines.runBlocking val runTrainingProcess: (ByteArray) -> ByteArray = { modelIn -> @@ -18,18 +19,24 @@ fun main() { runBlocking { val url: String? = System.getenv("FEDN_URL") val token: String? = System.getenv("FEDN_TOKEN") - val name: String? = System.getenv("FEDN_NAME") + var name: String? = System.getenv("FEDN_NAME") - if (url == null || token == null || name == null) { - println("FEDN_URL, FEDN_TOKEN and FEDN_NAME must be set") + if (url == null || token == null) { + println("FEDN_URL and FEDN_TOKEN must be set") return@runBlocking } println("FEDN_URL: $url") println("FEDN_TOKEN: $token") + + if (name == null) { + println("FEDN_NAME not set, using random name") + name = UUID.randomUUID().toString() + } println("FEDN_NAME: $name") - val fednClient: IFednClient = FednClient(url, token, name = name) + val fednClient: IFednClient = + FednClient(url, token, name = name, secureGrpcConnection = false) val result = fednClient.runProcess( @@ -41,7 +48,7 @@ fun main() { timeoutAfterMillis = 60000 ) - println("Result: ${result?.first}") + println("Result: ${result.first}") } println("Program ran to completion")