Skip to content

Commit

Permalink
👷 优化及拆分CI构建流程,增加dockerhub源推送
Browse files Browse the repository at this point in the history
  • Loading branch information
kwokronny committed Jul 4, 2024
1 parent ef86388 commit 0a363be
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 15 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
paths:
- 'packages/docs/**'
- 'CHANGELOG.md'
- ".github/workflows/deploy-doc.yml"

jobs:
build:
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docker Publish on Tag

on:
push:
tags:
- 'v*.*.*' # 只有符合vX.Y.Z格式的标签才会触发此工作流

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker image tags
id: tag
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
- name: Build and push to Docker Hub
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
tags: |
kwokronny68/roadbook:${{ steps.tag.outputs.version }}
kwokronny68/roadbook:latest
- name: Build and push to GitHub Container Registry
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
tags: |
ghcr.io/kwokronny/roadbook:${{ steps.tag.outputs.version }}
ghcr.io/kwokronny/roadbook:latest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Image CI
name: Release

on:
push:
Expand All @@ -7,7 +7,6 @@ on:
- "packages/roadbook-api/**"
- "packages/roadbook-vue/**"
- "Dockerfile"
- ".github/workflows/docker-image.yml"


jobs:
Expand Down Expand Up @@ -45,15 +44,3 @@ jobs:
git tag v${{env.RELEASE}}
git push origin v${{env.RELEASE}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build & Publish Docker Image
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/kwokronny/roadbook:latest, ghcr.io/kwokronny/roadbook:${{ env.RELEASE }}

0 comments on commit 0a363be

Please sign in to comment.