134 lines
3.6 KiB
YAML
134 lines
3.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- develop
|
|
paths:
|
|
- "bff/**"
|
|
- "product/**"
|
|
- "admin/**"
|
|
- "pkg/**"
|
|
- ".gitea/workflows/ci.yml"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: runner
|
|
outputs:
|
|
bff: ${{ steps.filter.outputs.bff }}
|
|
product: ${{ steps.filter.outputs.product }}
|
|
admin: ${{ steps.filter.outputs.admin }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://git.ailuowan.com/deploy/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Detect changes
|
|
id: filter
|
|
run: |
|
|
bff=false
|
|
product=false
|
|
admin=false
|
|
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
bff=true
|
|
product=true
|
|
admin=true
|
|
else
|
|
before="${{ github.event.before }}"
|
|
if [ -z "$before" ] || [ "$before" = "0000000000000000000000000000000000000000" ]; then
|
|
changed=$(git ls-files)
|
|
else
|
|
changed=$(git diff --name-only "$before" "${{ github.sha }}")
|
|
fi
|
|
|
|
echo "changed files:"
|
|
echo "$changed"
|
|
|
|
echo "$changed" | grep -qE '^(bff|pkg)/|^\.gitea/workflows/ci\.yml$' && bff=true || true
|
|
echo "$changed" | grep -qE '^(product|pkg)/|^\.gitea/workflows/ci\.yml$' && product=true || true
|
|
echo "$changed" | grep -qE '^(admin|pkg)/|^\.gitea/workflows/ci\.yml$' && admin=true || true
|
|
fi
|
|
|
|
echo "bff=$bff" >> "$GITHUB_OUTPUT"
|
|
echo "product=$product" >> "$GITHUB_OUTPUT"
|
|
echo "admin=$admin" >> "$GITHUB_OUTPUT"
|
|
echo "bff=$bff product=$product admin=$admin"
|
|
|
|
docker-bff:
|
|
needs: changes
|
|
if: needs.changes.outputs.bff == 'true'
|
|
runs-on: runner
|
|
env:
|
|
NAME: lone/bff
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://git.ailuowan.com/deploy/checkout@v4
|
|
|
|
- name: Login Registry
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ vars.REGISTRY }} -u "${{ vars.REGISTRY_USERNAME }}" --password-stdin
|
|
|
|
- name: Docker build
|
|
run: |
|
|
docker build \
|
|
-f bff/Dockerfile \
|
|
-t ${{ vars.REGISTRY }}/$NAME:latest \
|
|
.
|
|
|
|
- name: Docker push
|
|
run: |
|
|
docker push ${{ vars.REGISTRY }}/$NAME:latest
|
|
|
|
docker-product:
|
|
needs: changes
|
|
if: needs.changes.outputs.product == 'true'
|
|
runs-on: runner
|
|
env:
|
|
NAME: lone/product
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://git.ailuowan.com/deploy/checkout@v4
|
|
|
|
- name: Login Registry
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ vars.REGISTRY }} -u "${{ vars.REGISTRY_USERNAME }}" --password-stdin
|
|
|
|
- name: Docker build
|
|
run: |
|
|
docker build \
|
|
-f product/Dockerfile \
|
|
-t ${{ vars.REGISTRY }}/$NAME:latest \
|
|
.
|
|
|
|
- name: Docker push
|
|
run: |
|
|
docker push ${{ vars.REGISTRY }}/$NAME:latest
|
|
|
|
docker-admin:
|
|
needs: changes
|
|
if: needs.changes.outputs.admin == 'true'
|
|
runs-on: runner
|
|
env:
|
|
NAME: lone/admin
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://git.ailuowan.com/deploy/checkout@v4
|
|
|
|
- name: Login Registry
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ vars.REGISTRY }} -u "${{ vars.REGISTRY_USERNAME }}" --password-stdin
|
|
|
|
- name: Docker build
|
|
run: |
|
|
docker build \
|
|
-f admin/Dockerfile \
|
|
-t ${{ vars.REGISTRY }}/$NAME:latest \
|
|
.
|
|
|
|
- name: Docker push
|
|
run: |
|
|
docker push ${{ vars.REGISTRY }}/$NAME:latest
|