Skip to content

fix(vite-build): env file is supported in vite build #216

fix(vite-build): env file is supported in vite build

fix(vite-build): env file is supported in vite build #216

Workflow file for this run

name: Build and Push Images
on:
push:
branches: [ "main" ]
tags:
- v[0-9]+.[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+
pull_request:
branches: [ "main" ]
permissions:
contents: read
packages: write
env:
GO_VERSION: "1.25.1"
jobs:
build-and-push-frontend:
name: Build and Push Frontend Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get branch names.
id: branch-names
uses: tj-actions/branch-names@v8
# Build the image tag list. ghcr.io requires a lowercase repository path
# (the org login may contain uppercase, e.g. "Project-HAMi"). On a push to
# the default branch we additionally publish a :latest tag to GHCR only.
- name: Prepare image tags
run: |
owner="${GITHUB_REPOSITORY_OWNER,,}"
tag="${{ steps.branch-names.outputs.tag || steps.branch-names.outputs.current_branch == 'main' && 'main' || format('pr-{0}', github.run_number) }}"
{
echo "IMAGE_TAGS<<EOF"
echo "projecthami/hami-webui-fe-oss:${tag}"
echo "ghcr.io/${owner}/hami-webui-fe-oss:${tag}"
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
echo "ghcr.io/${owner}/hami-webui-fe-oss:latest"
fi
echo "EOF"
} >> "$GITHUB_ENV"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKERHUB_TOKEN }}
password: ${{ secrets.DOCKERHUB_PASSWD }}
- name: Log in to GHCR
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push frontend image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.IMAGE_TAGS }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-and-push-backend:
name: Build and Push Backend Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get branch names.
id: branch-names
uses: tj-actions/branch-names@v8
# Build the image tag list. ghcr.io requires a lowercase repository path
# (the org login may contain uppercase, e.g. "Project-HAMi"). On a push to
# the default branch we additionally publish a :latest tag to GHCR only.
- name: Prepare image tags
run: |
owner="${GITHUB_REPOSITORY_OWNER,,}"
tag="${{ steps.branch-names.outputs.tag || steps.branch-names.outputs.current_branch == 'main' && 'main' || format('pr-{0}', github.run_number) }}"
{
echo "IMAGE_TAGS<<EOF"
echo "projecthami/hami-webui-be-oss:${tag}"
echo "ghcr.io/${owner}/hami-webui-be-oss:${tag}"
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
echo "ghcr.io/${owner}/hami-webui-be-oss:latest"
fi
echo "EOF"
} >> "$GITHUB_ENV"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKERHUB_TOKEN }}
password: ${{ secrets.DOCKERHUB_PASSWD }}
- name: Log in to GHCR
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push backend image
uses: docker/build-push-action@v6
with:
context: ./server
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.IMAGE_TAGS }}
cache-from: type=gha
cache-to: type=gha,mode=max