Skip to content

Merge pull request #684 from naphelps/issue-675 #5

Merge pull request #684 from naphelps/issue-675

Merge pull request #684 from naphelps/issue-675 #5

Workflow file for this run

# Name of the workflow
name: build-push
# This workflow will run when there is a push (including merge) to the listed branches
on:
push:
branches:
- master
- v2.87
- v2.110
# Variables available to all jobs
env:
IMAGE_REPO: ${{ vars.DOCKERHUB_REPO }}
BUILD_NUMBER: ${{ github.run_number }}
# Jobs that will run when the workflow is triggered
jobs:
# This job will build and then push to docker hub
build-push:
# The type of runner the job will run on
runs-on: ubuntu-20.04
# Variables that are available to all steps in the job
env:
IMAGE_VERSION: ''
steps:
# Upgrade Docker engine version, needed for building images.
- name: Install Latest Docker Version
run: |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
# Authenticate Dockerhub to allow pushing to our image repo
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_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
run: |
VERSION=$(head -n 1 src/main/resources/version.txt)
echo "IMAGE_VERSION="${VERSION}"" >> $GITHUB_ENV
# Compile
- name: Compile
run: |
sbt compile
# Package
- name: Package
run: |
sbt package
# Docker Build and Publish Local
## When creating docker image sbt will ~for some reason~ mark the logs as [error] when it should be [info]
- name: Docker Build and Publish Local
run: |
sbt docker:publishLocal
# Push Docker images to Dockerhub
- name: Publish Image to Dockerhub
run: |
docker tag openhorizon/amd64_exchange-api:${IMAGE_VERSION} ${IMAGE_REPO}/amd64_exchange-api:${IMAGE_VERSION}-${BUILD_NUMBER}
docker tag openhorizon/amd64_exchange-api:${IMAGE_VERSION} ${IMAGE_REPO}/amd64_exchange-api:testing
docker push ${IMAGE_REPO}/amd64_exchange-api:${IMAGE_VERSION}-${BUILD_NUMBER}
if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then \
docker push ${IMAGE_REPO}/amd64_exchange-api:testing; \
fi