1+ name : Docker Build and Push
2+
3+ on :
4+ push :
5+ tags : [ "v*" ]
6+ workflow_dispatch :
7+
8+ jobs :
9+ build-and-push :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v4
13+
14+ - name : Login to Docker Hub
15+ uses : docker/login-action@v3
16+ with :
17+ username : ${{ secrets.DOCKER_HUB_USERNAME }}
18+ password : ${{ secrets.DOCKER_HUB_TOKEN }}
19+
20+ - name : Set up Docker Buildx
21+ uses : docker/setup-buildx-action@v3
22+ with :
23+ driver-opts : network=host
24+
25+ - name : Build and push
26+ uses : docker/build-push-action@v5
27+ with :
28+ context : .
29+ push : true
30+ platforms : linux/amd64,linux/arm64
31+ tags : |
32+ ${{ secrets.DOCKER_HUB_USERNAME }}/streamcap:latest
33+ ${{ secrets.DOCKER_HUB_USERNAME }}/streamcap:${{ github.sha }}
34+ ${{ github.ref == 'refs/heads/main' && format('{0}/streamcap:edge', secrets.DOCKER_HUB_USERNAME) || '' }}
35+ ${{ startsWith(github.ref, 'refs/tags/') && format('{0}/streamcap:{1}', secrets.DOCKER_HUB_USERNAME, github.ref_name) || '' }}
36+ cache-from : type=gha
37+ cache-to : type=gha,mode=max
38+
39+ - name : Notify build status
40+ if : always()
41+ uses : actions/github-script@v7
42+ with :
43+ script : |
44+ const status = ${{ job.status }}
45+ const message = status === 'success' ?
46+ 'Docker image built successfully!' :
47+ 'Docker image build failed, please check logs.'
48+ github.rest.issues.createComment({
49+ issue_number: context.issue.number,
50+ owner: context.repo.owner,
51+ repo: context.repo.repo,
52+ body: message
53+ })
0 commit comments