Skip to content

Merge pull request #600 from Steinbeck-Lab/development #69

Merge pull request #600 from Steinbeck-Lab/development

Merge pull request #600 from Steinbeck-Lab/development #69

Workflow file for this run

# This workflow will perform the following actions when a release is published:
# - Fetch Latest release.
# - Build the latest docker image in production.
# - Push the docker image to Github Artifact Registry-Prod.
#
# Maintainers:
# - name: Nisha Sharma
# - email: nisha.sharma@uni-jena.de
name: Prod Build, Test and Publish
# on:
# release:
# types: [published]
on:
push:
branches: [main]
# Set global environment variables
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
REPOSITORY_NAME: cheminformatics-microservice
REPOSITORY_NAMESPACE: nfdi4chem
jobs:
push_to_registry:
# Job to build and push Docker images
name: Push Docker images to Docker Hub
runs-on: ubuntu-latest
steps:
# Checkout code
- name: Check out the repo
uses: actions/checkout@v4
# Fetch latest GitHub release
- name: Fetch latest release
id: fetch-latest-release
uses: InsonusK/get-latest-release@v1.0.1
with:
myToken: ${{ github.token }}
exclude_types: "draft"
view_top: 10
# Docker Hub login
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ env.DOCKER_HUB_PASSWORD }}
# Build and push backend image
- name: Build and push full Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
build-args: |
RELEASE_VERSION=${{ steps.fetch-latest-release.outputs.tag_name }}
tags: |
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:${{ steps.fetch-latest-release.outputs.tag_name }}
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:latest
# Build and push lite version of backend image
- name: Build and push lite Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.lite
push: true
build-args: |
RELEASE_VERSION=${{ steps.fetch-latest-release.outputs.tag_name }}
tags: |
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:${{ steps.fetch-latest-release.outputs.tag_name }}-lite
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:latest-lite
# Check if frontend files have changed to optimize build process
- name: Check for frontend changes
uses: dorny/paths-filter@v2
id: frontend-changes
with:
filters: |
frontend:
- 'frontend/**'
# Build frontend Docker image only if frontend files changed
- name: Build and push frontend Docker image
uses: docker/build-push-action@v5.3.0
#if: steps.frontend-changes.outputs.frontend == 'true'
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
build-args: |
REACT_APP_API_URL=https://api.naturalproducts.net/latest
tags: |
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:app-${{ steps.fetch-latest-release.outputs.tag_name }}
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:app