Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] upgrade checkout action #1387

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Define version and branch
shell: bash
run: |
GIT_SOURCE_BRANCH=`([ "${GITHUB_HEAD_REF}" != "" ] && echo "${GITHUB_HEAD_REF}" || echo "${GITHUB_REF}") | sed 's/refs/heads/g' `
echo "GIT_SOURCE_BRANCH=$GIT_SOURCE_BRANCH" >> $GITHUB_ENV
SANITIZED_BRANCH=`echo ${GIT_SOURCE_BRANCH} | sed 's/[^a-zA-Z0-9.\-_]/\_/g' | awk '{print tolower($0)}'`
echo "VERSION_SUFFIX=-$SANITIZED_BRANCH-$(date -I)-$GITHUB_RUN_NUMBER-$GITHUB_SHA" >> $GITHUB_ENV
- name: Check variables
shell: bash
run: echo "$VERSION_SUFFIX $GIT_SOURCE_BRANCH"
- name: Cache ivy packages
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -49,7 +59,7 @@ jobs:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
with:
java-version: "openjdk@1.11"
Expand Down Expand Up @@ -81,7 +91,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Cache ivy packages
uses: actions/cache@v2
with:
Expand All @@ -107,7 +117,7 @@ jobs:
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Cache ivy packages
uses: actions/cache@v2
with:
Expand All @@ -133,7 +143,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Cache ivy packages
uses: actions/cache@v2
with:
Expand All @@ -159,7 +169,7 @@ jobs:
name: FrontendTests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Cache npm
uses: actions/cache@v2
with:
Expand All @@ -176,7 +186,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Cache npm
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -223,7 +233,7 @@ jobs:
#TODO: should we publish everything on all those branches?
if: ${{ github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/demo' || startsWith(github.head_ref, 'preview') }}
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Cache npm
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -267,5 +277,5 @@ jobs:
nexusPassword: ${{ secrets.SONATYPE_PASSWORD }}
addDevModel: ${{ github.ref == 'refs/heads/staging' }}
#TODO: handle version better, do we want to publish docker image for older scala versions? If so, how should it be tagged?
run: sbt -J-Xms1000M -J-Xmx1000M "set version in ThisBuild := (version in ThisBuild).value.replace(\"-SNAPSHOT\", \"-$(date -I)-$GITHUB_RUN_NUMBER-$GITHUB_SHA-SNAPSHOT\")" +publish dist/docker:publish
run: sbt -J-Xms1000M -J-Xmx1000M "set version in ThisBuild := (version in ThisBuild).value.replace(\"-SNAPSHOT\", \"${VERSION_SUFFIX}-SNAPSHOT\")" +publish dist/docker:publish

4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ lazy val dockerSettings = {

val updateLatest = if (dockerUpdateLatest.value) Some("latest") else None
val dockerVersion = Some(version.value)
val latestBranch = Some(git.gitCurrentBranch.value + "-latest")
//TODO: handle it more nicely, checkout actions in CI are not checking out actual branch
val currentBranch = sys.env.getOrElse("GIT_SOURCE_BRANCH", git.gitCurrentBranch.value)
val latestBranch = Some(currentBranch + "-latest")

List(dockerVersion, updateLatest, latestBranch, dockerTagName)
.map(tag => alias.withTag(tag.map(sanitize)))
Expand Down