Skip to content

Commit 55b4b0a

Browse files
authored
Create docker-image.yml
1 parent d88f593 commit 55b4b0a

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
# 设置 Docker Hub 凭证为环境变量
19+
- name: Log in to Docker Hub
20+
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
21+
22+
- name: Build the Docker image
23+
run: docker build . --file Dockerfile --tag devdocs:latest
24+
25+
# 将镜像推送到 Docker Hub
26+
- name: Push Docker image to Docker Hub
27+
run: |
28+
docker tag devdocs:latest ${{ secrets.DOCKERHUB_USERNAME }}/devdocs:latest
29+
docker push ${{ secrets.DOCKERHUB_USERNAME }}/devdocs:latest

0 commit comments

Comments
 (0)