Skip to content

Commit ffa5463

Browse files
authored
chore: app workflows (#15)
* feat: modified build.yml * chore: add build-preview.yml
1 parent ed83546 commit ffa5463

2 files changed

Lines changed: 81 additions & 19 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Docker Build and Push Preview
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main]
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-24.04
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Login to GitHub Container Registry
24+
if: github.event_name != 'pull_request'
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.repository_owner }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Build for amd64
32+
id: build
33+
uses: docker/build-push-action@v6
34+
with:
35+
context: .
36+
platforms: linux/amd64
37+
labels: |
38+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
39+
org.opencontainers.image.description=https://github.com/${{ github.repository }} image
40+
outputs: |
41+
type=image,
42+
name=ghcr.io/${{ github.repository_owner }}/FastGPT-plugin-pr:${{ github.sha }},
43+
push-by-digest=true,
44+
push=true
45+
cache-from: type=local,src=/tmp/.buildx-cache
46+
cache-to: type=local,dest=/tmp/.buildx-cache

.github/workflows/build.yml

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Docker Build and Push
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches: [main]
67
tags: ['v*']
@@ -13,7 +14,13 @@ permissions:
1314

1415
jobs:
1516
build:
16-
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
archs:
20+
- arch: amd64
21+
- arch: arm64
22+
runs-on: ubuntu-24.04-arm
23+
runs-on: ${{ matrix.archs.runs-on || 'ubuntu-24.04' }}
1724

1825
steps:
1926
- name: Checkout code
@@ -29,25 +36,34 @@ jobs:
2936
registry: ghcr.io
3037
username: ${{ github.repository_owner }}
3138
password: ${{ secrets.GITHUB_TOKEN }}
32-
33-
- name: Extract metadata for Docker
34-
id: meta
35-
uses: docker/metadata-action@v5
39+
- name: Login to Docker Hub
40+
if: github.event_name != 'pull_request'
41+
uses: docker/login-action@v3
42+
with:
43+
username: ${{ secrets.DOCKERHUB_USERNAME }}
44+
password: ${{ secrets.DOCKERHUB_TOKEN }}
45+
- name: Login to Ali Hub
46+
uses: docker/login-action@v3
3647
with:
37-
images: ghcr.io/${{ github.repository }}
38-
tags: |
39-
type=ref,event=branch
40-
type=ref,event=pr
41-
type=semver,pattern={{version}}
42-
type=semver,pattern={{major}}.{{minor}}
43-
type=sha,format=short
48+
registry: registry.cn-hangzhou.aliyuncs.com
49+
username: ${{ secrets.ALI_HUB_USERNAME }}
50+
password: ${{ secrets.ALI_HUB_PASSWORD }}
4451

45-
- name: Build and push Docker image
46-
uses: docker/build-push-action@v5
52+
- name: Build for ${{ matrix.archs.arch }}
53+
id: build
54+
uses: docker/build-push-action@v6
4755
with:
4856
context: .
49-
push: ${{ github.event_name != 'pull_request' }}
50-
tags: ${{ steps.meta.outputs.tags }}
51-
labels: ${{ steps.meta.outputs.labels }}
52-
cache-from: type=gha
53-
cache-to: type=gha,mode=max
57+
platforms: linux/${{ matrix.archs.arch }}
58+
labels: |
59+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
60+
org.opencontainers.image.description=https://github.com/${{ github.repository }} image
61+
outputs: |
62+
type=image,
63+
name=ghcr.io/${{ github.repository_owner }}/FastGPT-plugin:${{ github.sha }},
64+
${{ secrets.ALI_IMAGE_NAME }}/FastGPT-plugin:${{ github.sha }},
65+
${{ secrets.DOCKER_IMAGE_NAME }}/FastGPT-plugin:${{ github.sha }}
66+
push-by-digest=true,
67+
push=true
68+
cache-from: type=local,src=/tmp/.buildx-cache
69+
cache-to: type=local,dest=/tmp/.buildx-cache

0 commit comments

Comments
 (0)