Skip to content

Commit

Permalink
Merge branch 'master' into dependency-graph
Browse files Browse the repository at this point in the history
  • Loading branch information
naphelps committed Sep 11, 2023
2 parents 697b972 + acfaca5 commit 6d7cc13
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
67 changes: 37 additions & 30 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,48 @@ jobs:
# Ensure that the repo variables and secrets are set before running any other steps
- name: Check User Set Variables
run: |
if [[ -z "$DOCKER_USER" ]]; then \
echo "::error::Secret DOCKER_USER was not set"; \
exit 1; \
if [[ -z "$DOCKER_USER" ]]; then
echo "::error::Secret DOCKER_USER was not set"
exit 1
fi
if [[ -z "$DOCKER_TOKEN" ]]; then \
echo "::error::Secret DOCKER_TOKEN was not set"; \
exit 1; \
if [[ -z "$DOCKER_TOKEN" ]]; then
echo "::error::Secret DOCKER_TOKEN was not set"
exit 1
fi
if [[ -z "$IMAGE_REPO" ]]; then \
echo "::error::Variable DOCKERHUB_REPO was not set"; \
exit 1; \
if [[ -z "$IMAGE_REPO" ]]; then
echo "::error::Variable DOCKERHUB_REPO was not set"
exit 1
fi
if [[ -z "$RUN_NUMBER_OFFSET" ]]; then \
echo "::error::Variable RUN_NUMBER_OFFSET was not set"; \
exit 1; \
if [[ -z "$RUN_NUMBER_OFFSET" ]]; then
echo "::error::Variable RUN_NUMBER_OFFSET was not set"
exit 1
fi
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}

# Checkout our Github repo
- name: Checkout Github Repo
uses: actions/checkout@v3

# Offset our version build number to prevent collisions
- name: Offset Build Number
id: offset
- name: Configure Env Vars
run: |
echo "BUILD_NUMBER=$(($RUN_NUMBER + $RUN_NUMBER_OFFSET))" >> $GITHUB_ENV
BUILD_NUMBER=$(($RUN_NUMBER + $RUN_NUMBER_OFFSET))
echo "IMAGE_VERSION=$(head -n 1 src/main/resources/version.txt)-$BUILD_NUMBER" >> $GITHUB_ENV
echo "GIT_SHORT_SHA=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
- name: Validate Env Vars
run: |
echo "Using SHORT SHA: $GIT_SHORT_SHA"
if [[ -z "$GIT_SHORT_SHA" ]]; then
echo "::error::unable to get short sha from $GITHUB_SHA"
exit 1
fi
if [[ -z "$IMAGE_VERSION" ]]; then
echo "::error::unable to get IMAGE_VERSION"
exit 1
fi
# Upgrade Docker engine version, needed for building images.
- name: Install Latest Docker Version
Expand All @@ -64,6 +81,11 @@ jobs:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Setup Scala
# Comes from open source action: https://github.com/coursier/setup-action
- name: Setup Scala
uses: coursier/setup-action@v1

# Authenticate Dockerhub to allow pushing to our image repo
- name: Login to Dockerhub
uses: docker/login-action@v2
Expand All @@ -78,21 +100,6 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Checkout our Github repo
- name: Checkout Github Repo
uses: actions/checkout@v3

# Setup Scala
# Comes from open source action: https://github.com/coursier/setup-action
- name: Setup Scala
uses: coursier/setup-action@v1

# Configure version variables
- name: Config Version Variables
id: config-version
run: |
echo "IMAGE_VERSION=$(head -n 1 src/main/resources/version.txt)-$BUILD_NUMBER" >> $GITHUB_ENV

# Compile
- name: Compile
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ lazy val root = (project in file("."))
description := "'Containerized exchange-api'",
name := "amd64_exchange-api",
organization := "org.openhorizon",
release := versionFunc(),
release := sys.env.getOrElse("GIT_SHORT_SHA", versionFunc()),
resolvers += Classpaths.typesafeReleases,
scalaVersion := "2.13.10",
summary := "'Open Horizon exchange-api image'",
Expand Down

0 comments on commit 6d7cc13

Please sign in to comment.