mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 07:08:02 +00:00
chore: refactor publish workflow to separate build and deploy jobs, enhancing clarity and maintainability
This commit is contained in:
@@ -1,56 +1,84 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
username: fudaoyuanicu
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- uses: docker/metadata-action@v5
|
||||
id: meta
|
||||
with:
|
||||
images: fudaoyuanicu/015-app
|
||||
tags: |
|
||||
type=ref,event=tag
|
||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||
- name: Set build time
|
||||
id: build-time
|
||||
run: |
|
||||
echo "time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: build-app
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
VERSION=${{ gitea.ref_name || github.ref_name }}
|
||||
BUILD_TIME=${{ steps.build-time.outputs.time }}
|
||||
- name: build-worker
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./worker/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
- name: Send deployment webhook
|
||||
run: |
|
||||
curl -X POST http://192.168.100.5:8364/v1/update \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer helloworld"
|
||||
build-app:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
username: fudaoyuanicu
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- uses: docker/metadata-action@v5
|
||||
id: meta
|
||||
with:
|
||||
images: fudaoyuanicu/015-app
|
||||
tags: |
|
||||
type=pep440,pattern={{version}}
|
||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||
- name: Set build time
|
||||
id: build-time
|
||||
run: |
|
||||
echo "time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: build-app
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
VERSION=${{ gitea.ref_name || github.ref_name }}
|
||||
BUILD_TIME=${{ steps.build-time.outputs.time }}
|
||||
|
||||
build-worker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
username: fudaoyuanicu
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- uses: docker/metadata-action@v5
|
||||
id: meta
|
||||
with:
|
||||
images: fudaoyuanicu/015-worker
|
||||
tags: |
|
||||
type=pep440,pattern={{version}}
|
||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||
- name: Set build time
|
||||
id: build-time
|
||||
run: |
|
||||
echo "time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: build-worker
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./worker/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-app, build-worker]
|
||||
steps:
|
||||
- name: Send deployment webhook
|
||||
run: |
|
||||
curl -X POST http://192.168.100.5:8364/v1/update \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer helloworld"
|
||||
|
||||
Reference in New Issue
Block a user