-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
4 changed files
with
108 additions
and
27 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,47 @@ | ||
#!/usr/bin/env kotlin | ||
|
||
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.8.0") | ||
|
||
import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 | ||
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV4 | ||
import io.github.typesafegithub.workflows.actions.azure.DockerLoginV1 | ||
import io.github.typesafegithub.workflows.actions.docker.BuildPushActionV5 | ||
import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2 | ||
import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest | ||
import io.github.typesafegithub.workflows.domain.triggers.Release | ||
import io.github.typesafegithub.workflows.dsl.expressions.Contexts | ||
import io.github.typesafegithub.workflows.dsl.expressions.expr | ||
import io.github.typesafegithub.workflows.dsl.workflow | ||
import io.github.typesafegithub.workflows.yaml.writeToFile | ||
|
||
val version = expr { Contexts.github.ref } | ||
val DOCKER_HUB_USERNAME by Contexts.secrets | ||
val DOCKER_HUB_TOKEN by Contexts.secrets | ||
val dockerNamespace = "jopiterapp/jopiter-backend" | ||
|
||
workflow( | ||
name = "Release", | ||
on = listOf(Release()), | ||
sourceFile = __FILE__.toPath() | ||
) { | ||
job(id = "Release", runsOn = UbuntuLatest) { | ||
uses( | ||
name = "Setup JDK", | ||
action = SetupJavaV4(javaVersion = "17", distribution = SetupJavaV4.Distribution.Adopt) | ||
) | ||
uses(name = "Checkout", action = CheckoutV4()) | ||
uses(name = "Create ShadowJar", action = GradleBuildActionV2(arguments = ":bootJar")) | ||
uses( | ||
name = "Login to DockerHub", | ||
action = DockerLoginV1(username = expr { DOCKER_HUB_USERNAME }, password = expr { DOCKER_HUB_TOKEN }) | ||
) | ||
uses( | ||
name = "Build and Push", | ||
action = BuildPushActionV5( | ||
context = ".", | ||
push = true, | ||
tags = listOf("$dockerNamespace/latest", "$dockerNamespace/$version") | ||
) | ||
) | ||
} | ||
}.writeToFile() |
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 |
---|---|---|
@@ -1,30 +1,55 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- '**.md' | ||
# This file was generated using Kotlin DSL (.github/workflows/release.main.kts). | ||
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. | ||
# Generated with https://github.com/typesafegithub/github-workflows-kt | ||
|
||
name: 'Release' | ||
on: | ||
release: {} | ||
jobs: | ||
release: | ||
env: | ||
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_REGION: ${{ secrets.AWS_REGION }} | ||
runs-on: ubuntu-latest | ||
check_yaml_consistency: | ||
name: 'Check YAML consistency' | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- id: 'step-0' | ||
name: 'Check out' | ||
uses: 'actions/checkout@v4' | ||
- id: 'step-1' | ||
name: 'Execute script' | ||
run: 'rm ''.github/workflows/release.yaml'' && ''.github/workflows/release.main.kts''' | ||
- id: 'step-2' | ||
name: 'Consistency check' | ||
run: 'git diff --exit-code ''.github/workflows/release.yaml''' | ||
Release: | ||
runs-on: 'ubuntu-latest' | ||
needs: | ||
- 'check_yaml_consistency' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Create ShadowJar | ||
run: ./gradlew :bootJar | ||
- name: Deploy to Beanstalk | ||
uses: einaregilsson/beanstalk-deploy@v16 | ||
with: | ||
application_name: Jopiter Backend | ||
environment_name: Jopiterbackend-env | ||
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
region: sa-east-1 | ||
version_label: ${{ github.run_number }} | ||
deployment_package: build/libs/jopiter-backend.jar | ||
- id: 'step-0' | ||
name: 'Setup JDK' | ||
uses: 'actions/setup-java@v4' | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
- id: 'step-1' | ||
name: 'Checkout' | ||
uses: 'actions/checkout@v4' | ||
- id: 'step-2' | ||
name: 'Create ShadowJar' | ||
uses: 'gradle/gradle-build-action@v2' | ||
with: | ||
arguments: ':bootJar' | ||
- id: 'step-3' | ||
name: 'Login to DockerHub' | ||
uses: 'Azure/docker-login@v1' | ||
with: | ||
username: '${{ secrets.DOCKER_HUB_USERNAME }}' | ||
password: '${{ secrets.DOCKER_HUB_TOKEN }}' | ||
- id: 'step-4' | ||
name: 'Build and Push' | ||
uses: 'docker/build-push-action@v5' | ||
with: | ||
context: '.' | ||
push: 'true' | ||
tags: |- | ||
jopiterapp/jopiter-backend/latest | ||
jopiterapp/jopiter-backend/${{ github.ref }} |
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,4 @@ | ||
FROM eclipse-temurin:11 | ||
ADD build/libs/jopiter-uber.jar jopiter-uber.jar | ||
EXPOSE 5000 | ||
CMD java -jar jopiter-uber.jar |
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