Commit a08edc42 by Ryo Committed by GitHub

chore: update actions workflow yamls (#6835)

* chore: update actions workflow yamls

* fix: allow pro workflows on fork pull requests

* chore: update turbo.json

* fix: split admin preview image workflows

* chore: bump pro submodule for admin typecheck

* chore: update pro submodule
parent 18a35bfc
name: 'FastGPT-Pro-Test' name: "FastGPT-Pro-Test"
on: on:
pull_request: pull_request_target:
types: [ opened, synchronize, reopened ]
paths:
- "pro"
- "pro/**"
- "packages/**"
- "sdk/**"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- "turbo.json"
- ".gitmodules"
- ".github/workflows/fastgpt-pro-test.yaml"
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:
group: 'fastgpt-pro-test-${{ github.event.pull_request.number || github.ref }}' group: "fastgpt-pro-test-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
test: test:
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository || secrets.PRO_SUBMODULE_TOKEN != '' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
...@@ -19,17 +29,24 @@ jobs: ...@@ -19,17 +29,24 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
ref: ${{ github.event.pull_request.head.ref || github.ref }} ref: ${{ github.event_name == 'pull_request_target' &&
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} github.event.pull_request.head.sha || github.ref }}
repository: ${{ github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name || github.repository
}}
- name: Update submodules - name: Update submodules
env: env:
PRO_SUBMODULE_TOKEN: ${{ secrets.PRO_SUBMODULE_TOKEN }} PRO_SUBMODULE_TOKEN: ${{ secrets.PRO_SUBMODULE_TOKEN }}
run: | run: |
if [ -f .gitmodules ]; then if [ -f .gitmodules ]; then
if [ -z "${PRO_SUBMODULE_TOKEN}" ]; then
echo "::error::PRO_SUBMODULE_TOKEN is required to clone the private pro submodule. Add it to this repository's Actions secrets, or run this workflow from a repository that has the secret configured."
exit 1
fi
if [ -n "${PRO_SUBMODULE_TOKEN}" ]; then if [ -n "${PRO_SUBMODULE_TOKEN}" ]; then
git config --global url."https://x-access-token:${PRO_SUBMODULE_TOKEN}@github.com/".insteadOf "https://github.com/" git config --global url."https://x-access-token:${PRO_SUBMODULE_TOKEN}@github.com/".insteadOf "https://github.com/"
fi fi
git submodule update --init --recursive git submodule update --init --recursive --jobs 8
fi fi
- name: Install system deps for node-canvas - name: Install system deps for node-canvas
run: | run: |
...@@ -40,8 +57,8 @@ jobs: ...@@ -40,8 +57,8 @@ jobs:
version: 10.33.2 version: 10.33.2
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: '20' node-version: "24"
cache: 'pnpm' cache: "pnpm"
- name: Install Deps - name: Install Deps
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
- name: Test - name: Test
......
name: Preview Admin Image - Build & Push name: Preview Admin Image - Build
on: on:
pull_request_target: pull_request_target:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
paths:
- 'pro'
- 'pro/**'
- 'packages/**'
- 'sdk/**'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'turbo.json'
- '.gitmodules'
- '.github/workflows/preview-admin-build.yml'
- '.github/workflows/preview-admin-push.yml'
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:
group: 'preview-admin-build-${{ github.head_ref }}' group: 'preview-admin-build-${{ github.event.pull_request.number || github.ref }}'
cancel-in-progress: true cancel-in-progress: true
permissions: permissions:
contents: read contents: read
packages: write
pull-requests: write
issues: write
jobs: jobs:
build-and-push: build:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository || secrets.PRO_SUBMODULE_TOKEN != '' }}
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
steps: steps:
- name: Checkout PR code - name: Checkout PR code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: refs/pull/${{ github.event.pull_request.number }}/head ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0 repository: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name || github.repository }}
fetch-depth: 1
- name: Update submodules - name: Update submodules
env: env:
PRO_SUBMODULE_TOKEN: ${{ secrets.PRO_SUBMODULE_TOKEN }} PRO_SUBMODULE_TOKEN: ${{ secrets.PRO_SUBMODULE_TOKEN }}
run: | run: |
if [ -f .gitmodules ]; then if [ -f .gitmodules ]; then
if [ -z "${PRO_SUBMODULE_TOKEN}" ]; then
echo "::error::PRO_SUBMODULE_TOKEN is required to clone the private pro submodule. Add it to this repository's Actions secrets, or run this workflow from a repository that has the secret configured."
exit 1
fi
if [ -n "${PRO_SUBMODULE_TOKEN}" ]; then if [ -n "${PRO_SUBMODULE_TOKEN}" ]; then
git config --global url."https://x-access-token:${PRO_SUBMODULE_TOKEN}@github.com/".insteadOf "https://github.com/" git config --global url."https://x-access-token:${PRO_SUBMODULE_TOKEN}@github.com/".insteadOf "https://github.com/"
fi fi
...@@ -41,63 +53,33 @@ jobs: ...@@ -41,63 +53,33 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to Aliyun Container Registry - name: Build Docker image (no push)
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.FASTGPT_ALI_IMAGE_USER }}
password: ${{ secrets.FASTGPT_ALI_IMAGE_PSW }}
- name: Build and push Docker image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: . context: .
file: pro/admin/Dockerfile file: pro/admin/Dockerfile
platforms: linux/amd64 platforms: linux/amd64
push: true push: false
tags: ${{ secrets.FASTGPT_ALI_IMAGE_PREFIX }}/fastgpt-pro-pr:${{ github.event.pull_request.head.sha }} tags: fastgpt-pro-pr:${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
labels: | labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/FastGPT org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/FastGPT
org.opencontainers.image.description=fastgpt-pro admin image org.opencontainers.image.description=fastgpt-pro admin image
org.opencontainers.image.revision=${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
outputs: type=docker,dest=/tmp/fastgpt-pro-image.tar
cache-from: type=gha,scope=fastgpt-pro
cache-to: type=gha,mode=max,scope=fastgpt-pro
- name: Add PR comment on success - name: Save PR metadata
if: success() run: |
uses: actions/github-script@v7 echo "${{ github.event.pull_request.number || '' }}" > /tmp/pr-number.txt
with: echo "${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}" > /tmp/pr-sha.txt
script: |
const prNumber = ${{ github.event.pull_request.number }};
const marker = '<!-- fastgpt-admin-preview -->';
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existingComment = comments.find(comment =>
comment.body.includes(marker)
);
const commentBody = `${marker}
✅ **Admin Preview Image Ready!**
\`\`\`
${{ secrets.FASTGPT_ALI_IMAGE_PREFIX }}/fastgpt-pro-pr:${{ github.event.pull_request.head.sha }}
\`\`\`
`;
if (existingComment) { - name: Upload Docker image artifact
await github.rest.issues.updateComment({ uses: actions/upload-artifact@v4
owner: context.repo.owner, with:
repo: context.repo.repo, name: preview-admin-image
comment_id: existingComment.id, path: |
body: commentBody /tmp/fastgpt-pro-image.tar
}); /tmp/pr-number.txt
} else { /tmp/pr-sha.txt
await github.rest.issues.createComment({ retention-days: 1
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody
});
}
name: Preview Admin Image - Push
on:
workflow_run:
workflows: ['Preview Admin Image - Build']
types: [completed]
concurrency:
group: 'preview-admin-push'
cancel-in-progress: false
permissions:
contents: read
packages: write
attestations: write
id-token: write
pull-requests: write
issues: write
actions: read
jobs:
push:
runs-on: ubuntu-24.04
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: preview-admin-image
path: /tmp
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Read PR metadata
id: pr
run: |
echo "number=$(cat /tmp/pr-number.txt)" >> "$GITHUB_OUTPUT"
echo "sha=$(cat /tmp/pr-sha.txt)" >> "$GITHUB_OUTPUT"
- name: Load Docker image
run: docker load --input /tmp/fastgpt-pro-image.tar
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Aliyun Container Registry
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.FASTGPT_ALI_IMAGE_USER }}
password: ${{ secrets.FASTGPT_ALI_IMAGE_PSW }}
- name: Tag and push Docker image
run: |
SHA="${{ steps.pr.outputs.sha }}"
docker tag fastgpt-pro-pr:${SHA} \
${{ secrets.FASTGPT_ALI_IMAGE_PREFIX }}/fastgpt-pro-pr:${SHA}
docker push ${{ secrets.FASTGPT_ALI_IMAGE_PREFIX }}/fastgpt-pro-pr:${SHA}
- name: Add PR comment on success
if: success() && steps.pr.outputs.number != ''
uses: actions/github-script@v7
with:
script: |
const prNumber = parseInt('${{ steps.pr.outputs.number }}');
const marker = '<!-- fastgpt-admin-preview -->';
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existingComment = comments.find(comment =>
comment.body.includes(marker)
);
const commentBody = `${marker}
✅ **Admin Preview Image Ready!**
\`\`\`
${{ secrets.FASTGPT_ALI_IMAGE_PREFIX }}/fastgpt-pro-pr:${{ steps.pr.outputs.sha }}
\`\`\`
`;
if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: commentBody
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody
});
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"version": "4.0", "version": "4.0",
"private": true, "private": true,
"scripts": { "scripts": {
"proDev": "turbo run dev --filter=@fastgpt/app", "dev:pro": "turbo run dev:pro --filter=@fastgpt/app",
"prepare": "husky install", "prepare": "husky install",
"gen:theme-typings": "chakra-cli tokens packages/web/styles/theme.ts --out node_modules/.pnpm/node_modules/@chakra-ui/styled-system/dist/theming.types.d.ts", "gen:theme-typings": "chakra-cli tokens packages/web/styles/theme.ts --out node_modules/.pnpm/node_modules/@chakra-ui/styled-system/dist/theming.types.d.ts",
"postinstall": "pnpm gen:theme-typings && pnpm run build:sdks", "postinstall": "pnpm gen:theme-typings && pnpm run build:sdks",
......
packages: packages:
- packages/* - packages/*
- projects/* - projects/*
- pro/admin
- pro/sso
- scripts/icon - scripts/icon
- sdk/* - sdk/*
- pro/admin
- pro/sso
catalog: catalog:
"@fastgpt-sdk/logger": 0.1.2 "@fastgpt-sdk/logger": 0.1.2
"@fastgpt-sdk/otel": 0.1.2 "@fastgpt-sdk/otel": 0.1.2
......
Subproject commit 3b9a14da941d603ac4065dc0f4fec049f630348a Subproject commit 1d38337167baeed33ece061772c84b0ccce71333
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
"version": "4.14.16", "version": "4.14.16",
"private": false, "private": false,
"scripts": { "scripts": {
"dev": "NODE_OPTIONS='--max-old-space-size=8192' pnpm run build:workers && next dev", "dev": "pnpm run build:workers && next dev",
"dev:pro": "pnpm run dev",
"build": "pnpm run build:workers && next build --debug", "build": "pnpm run build:workers && next build --debug",
"build:webpack": "pnpm run build:workers && next build --webpack --debug", "build:webpack": "pnpm run build:workers && next build --webpack --debug",
"analyze": "next experimental-analyze", "analyze": "next experimental-analyze",
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
"cache": false, "cache": false,
"persistent": true "persistent": true
}, },
"dev:pro": {
"with": ["@fastgpt/admin#dev"],
"cache": false,
"persistent": true
},
"build": { "build": {
"dependsOn": ["^build"], "dependsOn": ["^build"],
"outputs": [".next/**", "dist/**", "worker/**"] "outputs": [".next/**", "dist/**", "worker/**"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment