Skip to content

Commit af988b9

Browse files
committed
refactor: 重构 Docker 镜像 CI 流程,合并构建和推送步骤
1 parent 5176e7a commit af988b9

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

.github/workflows/docker-image.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,35 @@ name: Docker Image CI
33
on:
44
push:
55
branches: [ "master" ]
6+
tags:
7+
- 'v*'
68
pull_request:
79
branches: [ "master" ]
810

911
jobs:
10-
11-
build:
12-
12+
build-and-push:
1313
runs-on: ubuntu-latest
1414

15+
if: github.event_name != 'pull_request'
16+
1517
steps:
16-
- uses: actions/checkout@v4
17-
- name: Build the Docker image
18-
run: docker build . --file Dockerfile --tag e1saps/onebot-github-webhook:$(date +%s)
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Login to Docker Hub
25+
uses: docker/login-action@v3
26+
with:
27+
username: ${{ secrets.DOCKERHUB_USERNAME }}
28+
password: ${{ secrets.DOCKERHUB_TOKEN }}
29+
30+
- name: Build and push
31+
uses: docker/build-push-action@v5
32+
with:
33+
context: .
34+
push: ${{ github.event_name != 'pull_request' }}
35+
tags: |
36+
e1saps/onebot-github-webhook:latest
37+
${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && format('e1saps/onebot-github-webhook:{0}', github.ref_name) || format('e1saps/onebot-github-webhook:{0}', github.sha) }}

0 commit comments

Comments
 (0)