Skip to content

Merge branch 'main' of https://github.com/LiteyukiStudio/agent #62

Merge branch 'main' of https://github.com/LiteyukiStudio/agent

Merge branch 'main' of https://github.com/LiteyukiStudio/agent #62

Workflow file for this run

name: Build and Push Docker Images
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
packages: write
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Determine tags
id: meta
run: |
REPO="${{ secrets.DOCKERHUB_USERNAME }}/liteyuki-flow-backend"
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/v}"
echo "tags=${REPO}:${VERSION},${REPO}:latest" >> $GITHUB_OUTPUT
else
echo "tags=${REPO}:latest,${REPO}:nightly" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push backend image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-and-push-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Determine tags
id: meta
run: |
REPO="${{ secrets.DOCKERHUB_USERNAME }}/liteyuki-flow-frontend"
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/v}"
echo "tags=${REPO}:${VERSION},${REPO}:latest" >> $GITHUB_OUTPUT
else
echo "tags=${REPO}:latest,${REPO}:nightly" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push frontend image
uses: docker/build-push-action@v5
with:
context: .
file: web/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
runs-on: ubuntu-latest
needs: [build-and-push-backend, build-and-push-frontend]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "$PREV_TAG"..HEAD)
else
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --max-count=30)
fi
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref_name }}
name: "Liteyuki Flow ${{ github.ref_name }}"
body: |
## Liteyuki Flow ${{ github.ref_name }}
### Docker 部署
```bash
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/liteyuki-flow-backend:${{ github.ref_name }}
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/liteyuki-flow-frontend:${{ github.ref_name }}
```
### 更新日志
${{ steps.changelog.outputs.changelog }}
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}