Skip to content

Merge pull request #258 from sugarcane-ai/new_build_structure #345

Merge pull request #258 from sugarcane-ai/new_build_structure

Merge pull request #258 from sugarcane-ai/new_build_structure #345

name: Build Factory Image
on:
workflow_dispatch:
push:
branches:
- develop
- main
- build-*
- prod
pull_request:
branches:
- main
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
SHORT_SHA: ${{ github.sha || github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.12.2
check-latest: true
# - name: Change to factory directory
# run: cd apps/factory
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
# - name: Npm version name
# run: echo running on branch ${NPM_PACKAGE_VERSION} --- ${GITHUB_ENV}
- name: Build Docker Image
uses: docker/[email protected]
with:
context: apps/factory # Specify the directory where Dockerfile is located
# file: Dockerfile # Specify the path to your Dockerfi
build-args: |
"PROJECT_NAME=factory"
tags: |
${{ secrets.DOCKER_REPO_FACTORY }}:${{ env.BRANCH_NAME }}-latest
${{ secrets.DOCKER_REPO_FACTORY }}:${{ env.SHORT_SHA }}
push: true
# cache-from: type=gha
# cache-to: type=gha,mode=max
cache-from: type=registry,ref=${{ secrets.DOCKER_REPO_FACTORY }}:buildcache
cache-to: type=inline
# cache-to: type=registry,ref=${{ secrets.DOCKER_REPO_FACTORY }}:buildcache,mode=max