Skip to content

Commit

Permalink
Merge pull request #640 from softwaremill/deploy-on-release
Browse files Browse the repository at this point in the history
Deploy on GH release event
  • Loading branch information
adamw authored Jun 22, 2021
2 parents 86de2a5 + 2f268a0 commit 32181dd
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 52 deletions.
4 changes: 4 additions & 0 deletions .github/release-drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
template: |
## What’s Changed
$CHANGES
6 changes: 4 additions & 2 deletions .github/workflows/bootzooka-helm-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on:
paths:
- "helm/**"
- ".github/**"
branches:
- master
pull_request:
paths:
- "helm/**"
- ".github/**"

jobs:
lint-chart:
# run on external PRs, but not on internal PRs since those will be run by push to branch
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
name: Lint Helm Chart
runs-on: ubuntu-18.04
steps:
Expand Down Expand Up @@ -86,6 +86,8 @@ jobs:
run: git diff --exit-code

publish-chart:
# run only on push to master
if: github.event_name == 'push'
needs:
- lint-chart
- install-test-chart
Expand Down
62 changes: 57 additions & 5 deletions .github/workflows/bootzooka-scala-ts-ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: Bootzooka CI

on:
pull_request:
push:
tags: [v*]
branches:
- master
paths-ignore:
- "helm/**"
pull_request:
release:
types:
- released
paths-ignore:
- "helm/**"

jobs:
scala-ts-tests:
# run on external PRs, but not on internal PRs since those will be run by push to branch
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
name: CI
test:
name: Test
runs-on: ubuntu-18.04

steps:
Expand All @@ -39,3 +43,51 @@ jobs:
- name: Run tests
id: run-tests
run: sbt test

deploy:
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v')
needs: [ test ]
runs-on: ubuntu-latest

steps:
- name: Check-out repository
id: repo-checkout
uses: actions/checkout@v2

- name: Set up JDK 11
id: jdk-setup
uses: actions/setup-java@v1
with:
java-version: 11

- name: Cache SBT
id: cache-sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version
run: |
version=${GITHUB_REF/refs\/tags\/v/}
echo "VERSION=$version" >> $GITHUB_ENV
- name: Publish release notes
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: true
name: "v${{ env.VERSION }}"
tag: "v${{ env.VERSION }}"
version: "v${{ env.VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish docker image
run: sbt docker:publish
27 changes: 10 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sbtbuildinfo.BuildInfoKey.action
import sbtbuildinfo.BuildInfoKeys.{buildInfoKeys, buildInfoOptions, buildInfoPackage}
import sbtbuildinfo.{BuildInfoKey, BuildInfoOption}
import com.typesafe.sbt.packager.docker.ExecCmd

import sbt._
import Keys._
Expand Down Expand Up @@ -156,29 +155,23 @@ lazy val fatJarSettings = Seq(
}
)


lazy val dockerSettings = Seq(
dockerExposedPorts := Seq(8080),
dockerBaseImage := "adoptopenjdk:11.0.5_10-jdk-hotspot",
Docker / packageName := "bootzooka",
dockerUsername := Some("softwaremill"),
dockerCommands := {
dockerCommands.value.flatMap {
case ep @ ExecCmd("ENTRYPOINT", _*) =>
Seq(
ExecCmd("ENTRYPOINT", "/opt/docker/docker-entrypoint.sh" :: ep.args.toList: _*)
)
case other => Seq(other)
}
},
Docker / mappings ++= {
val scriptDir = baseDirectory.value / ".." / "scripts"
val entrypointScript = scriptDir / "docker-entrypoint.sh"
val entrypointScriptTargetPath = "/opt/docker/docker-entrypoint.sh"
Seq(entrypointScript -> entrypointScriptTargetPath)
},
dockerUpdateLatest := true,
Docker / publishLocal := (Docker / publishLocal).dependsOn(copyWebapp).value,
Docker / version := git.gitHeadCommit.value.map(head => now() + "-" + head.take(8)).getOrElse("latest")
Docker / version := git.gitDescribedVersion.value.getOrElse(git.formattedShaVersion.value.getOrElse("latest")),
git.uncommittedSignifier := Some("dirty"),
ThisBuild / git.formattedShaVersion := {
val base = git.baseVersion.?.value
val suffix = git.makeUncommittedSignifierSuffix(git.gitUncommittedChanges.value, git.uncommittedSignifier.value)
git.gitHeadCommit.value.map { sha =>
git.defaultFormatShaVersion(base, sha.take(7), suffix)
}
}
)

def haltOnCmdResultError(result: Int) {
Expand Down
27 changes: 0 additions & 27 deletions scripts/docker-entrypoint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.0.1-SNAPSHOT"
ThisBuild / version := "0.0.1-SNAPSHOT"

0 comments on commit 32181dd

Please sign in to comment.