first commit
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
paths:
|
||||
- "bff/**"
|
||||
- "product/**"
|
||||
- "pkg/**"
|
||||
- ".gitea/workflows/ci.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
runs-on: runner
|
||||
outputs:
|
||||
bff: ${{ steps.filter.outputs.bff }}
|
||||
product: ${{ steps.filter.outputs.product }}
|
||||
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
|
||||
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
bff=true
|
||||
product=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
|
||||
fi
|
||||
|
||||
echo "bff=$bff" >> "$GITHUB_OUTPUT"
|
||||
echo "product=$product" >> "$GITHUB_OUTPUT"
|
||||
echo "bff=$bff product=$product"
|
||||
|
||||
docker-bff:
|
||||
needs: changes
|
||||
if: needs.changes.outputs.bff == 'true'
|
||||
runs-on: runner
|
||||
env:
|
||||
NAME: lone/bff
|
||||
CONTEXT: ./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 \
|
||||
-t ${{ vars.REGISTRY }}/$NAME:latest \
|
||||
$CONTEXT
|
||||
|
||||
- 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
|
||||
CONTEXT: ./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 \
|
||||
-t ${{ vars.REGISTRY }}/$NAME:latest \
|
||||
$CONTEXT
|
||||
|
||||
- name: Docker push
|
||||
run: |
|
||||
docker push ${{ vars.REGISTRY }}/$NAME:latest
|
||||
Reference in New Issue
Block a user