Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,21 @@ jobs:
/tmp/pr-sha.txt
/tmp/package-changes.txt
retention-days: 1

call-push-workflow:
needs: build
permissions:
contents: read
packages: write
attestations: write
id-token: write
pull-requests: write
Comment thread
c121914yu marked this conversation as resolved.
Outdated
uses: ./.github/workflows/preview-push.yml
secrets:
ALI_IMAGE_USER: ${{ secrets.FASTGPT_ALI_IMAGE_USER }}
ALI_IMAGE_PSW: ${{ secrets.FASTGPT_ALI_IMAGE_PSW }}
ALI_IMAGE_PREFIX: ${{ secrets.FASTGPT_ALI_IMAGE_PREFIX }}
with:
pr_number: ${{ format('{0}', github.event.pull_request.number) }}
sha: ${{ github.event.pull_request.head.sha }}
run_id: ${{ format('{0}', github.run_id) }}
41 changes: 27 additions & 14 deletions .github/workflows/preview-push.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
name: Preview Image — Push

on:
workflow_run:
workflows: ["Preview Image — Build"]
types: [completed]
workflow_call:
inputs:
pr_number:
required: true
type: string
sha:
required: true
type: string
run_id:
required: true
type: string
secrets:
ALI_IMAGE_USER:
required: true
ALI_IMAGE_PSW:
required: true
ALI_IMAGE_PREFIX:
required: true

# Only one push at a time
concurrency:
Expand All @@ -21,23 +36,21 @@ permissions:
jobs:
push:
runs-on: ubuntu-24.04
# Only push when the build succeeded
if: ${{ github.event.workflow_run.conclusion == 'success' }}

steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: preview-image
path: /tmp
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
run-id: ${{ inputs.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"
echo "number=${{ inputs.pr_number }}" >> "$GITHUB_OUTPUT"
echo "sha=${{ inputs.sha }}" >> "$GITHUB_OUTPUT"
echo "package_changes=$(cat /tmp/package-changes.txt)" >> "$GITHUB_OUTPUT"

- name: Load Docker image
Expand All @@ -50,14 +63,14 @@ jobs:
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALI_HUB_USERNAME }}
password: ${{ secrets.ALI_HUB_PASSWORD }}
username: ${{ secrets.ALI_IMAGE_USER }}
password: ${{ secrets.ALI_IMAGE_PSW }}

- name: Tag and push Docker image
run: |
docker tag fastgpt-plugin-pr:${{ steps.pr.outputs.sha }} \
${{ secrets.ALI_IMAGE_NAME }}/fastgpt-plugin-pr:${{ steps.pr.outputs.sha }}
docker push ${{ secrets.ALI_IMAGE_NAME }}/fastgpt-plugin-pr:${{ steps.pr.outputs.sha }}
${{ secrets.ALI_IMAGE_PREFIX }}/fastgpt-plugin-pr:${{ steps.pr.outputs.sha }}
docker push ${{ secrets.ALI_IMAGE_PREFIX }}/fastgpt-plugin-pr:${{ steps.pr.outputs.sha }}

- name: Add PR comment on success
if: success() && steps.pr.outputs.number != ''
Expand All @@ -81,7 +94,7 @@ jobs:
✅ **Build Successful** - Preview Images for this PR:

\`\`\`
${{ secrets.ALI_IMAGE_NAME }}/fastgpt-plugin-pr:${{ steps.pr.outputs.sha }}
${{ secrets.ALI_IMAGE_PREFIX }}/fastgpt-plugin-pr:${{ steps.pr.outputs.sha }}
\`\`\`

Comment thread
c121914yu marked this conversation as resolved.
**Changed packages:**
Expand Down
Loading