Skip to content

Build and Upload Docker Image #8

Build and Upload Docker Image

Build and Upload Docker Image #8

Workflow file for this run

name: Build and Upload Docker Image
on:
push:
branches:
- main # Trigger the workflow on push or pull request to the main branch
workflow_dispatch: # Trigger the workflow manually from the Actions tab
jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Scala 2.13.10 and sbt 1.8.2
uses: olafurpg/setup-scala@v13
with:
java-version: adopt@1.11 # Set up JDK 11
scala-version: 2.13.10
sbt-version: 1.8.2
- name: Extract version
id: get_version
run: echo "$(grep -oP '(?<=ThisBuild / version := ").*(?=")' build.sbt)" > ${{ github.workspace }}/version.txt
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
run: sbt clean docker:publishLocal
- name: Tag Docker image
run: |
VERSION=$(cat ${{ github.workspace }}/version.txt)
docker tag projectemo:$VERSION ghcr.io/vega113/projectemo:$VERSION
- name: Push Docker image
run: |
VERSION=$(cat ${{ github.workspace }}/version.txt)
docker push ghcr.io/vega113/projectemo:$VERSION