Skip to content

up

up #3416

Workflow file for this run

name: backend
on:
push:
env:
DOCKER_IMAGE_NAME: ghcr.io/loculus-project/backend
defaults:
run:
working-directory: ./backend
concurrency:
group: ci-${{ github.ref }}-backend
cancel-in-progress: true
jobs:
Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "adopt"
- name: Execute Tests
uses: gradle/gradle-build-action@v3
with:
arguments: test
build-root-directory: ./backend
- name: Check Format And Lint
uses: gradle/gradle-build-action@v3
with:
arguments: ktlintCheck
build-root-directory: ./backend
dockerImage:
name: Build Backend Docker Image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
checks: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "adopt"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: dockerMetadata
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=sha,prefix=commit-
- name: Extract Docker Tags
id: extractTag
run: |
FIRST_TAG=$(echo "${{ steps.dockerMetadata.outputs.tags }}" | head -n 1)
echo "firstTag=$FIRST_TAG" >> $GITHUB_OUTPUT
SECOND_TAG=$(echo "${{ steps.dockerMetadata.outputs.tags }}" | head -n 2 | tail -n 1)
echo "secondTag=$SECOND_TAG" >> $GITHUB_OUTPUT
- name: Build Docker Image For Branch
uses: gradle/gradle-build-action@v3
env:
USER: ${{ github.actor }}
TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
arguments: bootBuildImage --imageName=${{steps.extractTag.outputs.firstTag }}
build-root-directory: ./backend
- name: Tag With SHA tag
run: docker tag ${{ steps.extractTag.outputs.firstTag }} ${{ steps.extractTag.outputs.secondTag }}
- name: Push 1st Docker Image
run: docker push ${{ steps.extractTag.outputs.firstTag }}
- name: Push 2nd Docker Image
run: docker push ${{ steps.extractTag.outputs.secondTag }}