Skip to content

fix: update pnpm lockfile #102

fix: update pnpm lockfile

fix: update pnpm lockfile #102

name: Build and Push Docker Images
on:
push:
branches:
- staging
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.package-info.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: true
- name: Extract version and service name
id: package-info
run: |
if [ -z "${{ inputs.path }}" ] || [ "${{ inputs.path }}" = "" ]; then
SERVICES='["owl-api", "lark-ui"]'
else
SERVICES="[\"${{ inputs.path }}\"]"
fi
MATRIX="[]"
for SERVICE in $(echo "$SERVICES" | jq -r '.[]'); do
if [ -f "./$SERVICE/package.json" ]; then
VERSION=$(jq -r '.version' "./$SERVICE/package.json")
MATRIX=$(echo "$MATRIX" | jq --arg service "$SERVICE" --arg version "$VERSION" '. += [{"service": $service, "version": $version}]')
fi
done
echo "matrix<<EOF" >> $GITHUB_OUTPUT
echo "$MATRIX" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
build:
needs: prepare
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate build ID
id: prep
run: |
branch=${GITHUB_REF##*/}
sha=${GITHUB_SHA::8}
ts=$(date +%s)
build_id="${branch}-${sha}-${ts}"
echo "build_id=${build_id}" >> $GITHUB_OUTPUT
echo "timestamp=${ts}" >> $GITHUB_OUTPUT
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: ./${{ matrix.service }}/Dockerfile
tags: |
ghcr.io/${{ github.repository }}/staging-${{ matrix.service }}:latest
ghcr.io/${{ github.repository }}/staging-${{ matrix.service }}:${{ steps.prep.outputs.build_id }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Trigger Flux webhook for owl-api
if: matrix.service == 'owl-api'
run: |
curl -X POST "${{ secrets.FLUX_BACKEND_WEBHOOK_URL }}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ secrets.FLUX_WEBHOOK_TOKEN }}" \
-d '{"ref": "main"}'
- name: Trigger Flux webhook for lark-ui
if: matrix.service == 'lark-ui'
run: |
curl -X POST "${{ secrets.FLUX_FRONTEND_WEBHOOK_URL }}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ secrets.FLUX_WEBHOOK_TOKEN }}" \
-d '{"ref": "main"}'