Skip to content

Commit

Permalink
Use GitHub Container Registry (#848)
Browse files Browse the repository at this point in the history
Co-authored-by: hfhbd <[email protected]>
  • Loading branch information
hfhbd and hfhbd authored Dec 13, 2023
1 parent 7f28283 commit 20959fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,14 @@ jobs:
run: long="${{ github.ref }}"; version=${long#"refs/tags/v"}; echo "version=${version}" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
run: echo "${{ github.token }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- id: auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.RUN_SA_KEY }}
- uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.PROJECT_ID }}
- name: Login to Google Container Registry
run: gcloud auth configure-docker "eu.gcr.io" --quiet

- uses: actions/configure-pages@v4
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 17
- uses: gradle/gradle-build-action@v2
- name: Push Docker Image to GitHub
run: ./gradlew -Pversion=$version -Pregistry=GitHub jib --no-configuration-cache
- name: Push Docker Image to Google Container Registry
run: ./gradlew -Pversion=$version -Pregistry=Google -Pproject_id=${{ secrets.PROJECT_ID }} -Pservice_name=$service_name jib --no-configuration-cache
run: ./gradlew -Pversion=$version jib --no-configuration-cache
- name: Assemble with Gradle
run: ./gradlew :web:jsBrowserDistribution
- uses: actions/upload-pages-artifact@v2
Expand Down Expand Up @@ -83,7 +71,7 @@ jobs:
gcloud run deploy "$service_name" \
--quiet \
--region "europe-west4" \
--image "eu.gcr.io/${{ secrets.PROJECT_ID }}/$service_name:$version" \
--image "ghcr.io/hfhbd/composetodo:$version" \
--platform "managed" \
--allow-unauthenticated \
--set-env-vars keyID="${{ secrets.CK_KEYID }}",privateKey=${{ secrets.CK_KEY}} \
Expand Down
16 changes: 3 additions & 13 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,13 @@ plugins {
id("license")
}

kotlin.jvmToolchain(17)
kotlin.jvmToolchain(21)

jib {
val registry: String? by project
to.image = when (registry) {
"GitHub" -> "ghcr.io/hfhbd/composetodo:$version"
"Google" -> {
val project_id: String by project
val service_name: String by project
"eu.gcr.io/$project_id/$service_name:$version"
}

else -> return@jib
}
to.image = "ghcr.io/hfhbd/composetodo:$version"

from {
image = "eclipse-temurin:17-jre"
image = "eclipse-temurin:21-jre"

platforms {
platform {
Expand Down

0 comments on commit 20959fc

Please sign in to comment.