mirror of
https://github.com/ihmily/StreamCap.git
synced 2026-07-01 03:44:24 +08:00
ci: add docker build workflow
This commit is contained in:
53
.github/workflows/docker-build.yml
vendored
Normal file
53
.github/workflows/docker-build.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
name: Docker Build and Push
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: [ "v*" ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver-opts: network=host
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
${{ secrets.DOCKER_HUB_USERNAME }}/streamcap:latest
|
||||
${{ secrets.DOCKER_HUB_USERNAME }}/streamcap:${{ github.sha }}
|
||||
${{ github.ref == 'refs/heads/main' && format('{0}/streamcap:edge', secrets.DOCKER_HUB_USERNAME) || '' }}
|
||||
${{ startsWith(github.ref, 'refs/tags/') && format('{0}/streamcap:{1}', secrets.DOCKER_HUB_USERNAME, github.ref_name) || '' }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Notify build status
|
||||
if: always()
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const status = ${{ job.status }}
|
||||
const message = status === 'success' ?
|
||||
'Docker image built successfully!' :
|
||||
'Docker image build failed, please check logs.'
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: message
|
||||
})
|
||||
Reference in New Issue
Block a user