Skip to content

Commit

Permalink
feat: auto build
Browse files Browse the repository at this point in the history
  • Loading branch information
tithanayut committed Feb 4, 2025
1 parent fb0aa96 commit 6005986
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 8 deletions.
36 changes: 28 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
name: Build

on:
workflow_dispatch:
inputs:
APP_DIR:
description: "Directory of the service to build"
required: true
type: string
push:
branches:
- main

jobs:
changes:
runs-on: ubuntu-latest
outputs:
apps: ${{ steps.filter.outputs.changes }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Filter changed paths
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
account/server:
- 'account/server/**'
auth/server:
- 'auth/server/**'
build:
needs: changes
runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.apps != '' && toJson(fromJson(needs.changes.outputs.apps)) != '[]' }}
strategy:
matrix:
APP_DIR: ${{ fromJSON(needs.changes.outputs.apps) }}
permissions:
contents: read
packages: write
Expand All @@ -34,8 +54,8 @@ jobs:
context: .
file: ./docker/Dockerfile
push: true
tags: ghcr.io/noah-platform/noah/${{ github.event.inputs.APP_DIR }}:latest
tags: ghcr.io/noah-platform/noah/${{ matrix.APP_DIR }}:latest
build-args: |
APP_DIR=${{ github.event.inputs.APP_DIR }}
APP_DIR=${{ matrix.APP_DIR }}
cache-from: type=gha
cache-to: type=gha,mode=max
41 changes: 41 additions & 0 deletions .github/workflows/manual-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Manual Build

on:
workflow_dispatch:
inputs:
APP_DIR:
description: "Directory of the service to build"
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to the Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
push: true
tags: ghcr.io/noah-platform/noah/${{ github.event.inputs.APP_DIR }}:latest
build-args: |
APP_DIR=${{ github.event.inputs.APP_DIR }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 6005986

Please sign in to comment.