Skip to content

Commit 9403d5b

Browse files
committed
chore: 修改推送的镜像名称为分支名,增加release
1 parent 8d09266 commit 9403d5b

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/docker-build.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,20 @@ jobs:
2121

2222
- name: Extract repository name
2323
id: extract_repo_name
24-
run: echo "REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)" >> $GITHUB_ENV
24+
run: echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
2525

2626
- name: Build and push Docker image
2727
uses: docker/build-push-action@v2
2828
with:
2929
context: .
3030
push: true
3131
tags: ${{ secrets.DOCKER_USERNAME }}/${{ env.REPO_NAME }}:latest
32+
33+
- name: Create or update GitHub Release
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
run: |
37+
RELEASE_NAME="Build for branch ${{ env.BRANCH_NAME }}"
38+
RELEASE_BODY="Docker image has been built and pushed successfully.\n\nTag: ${{ secrets.DOCKER_USERNAME }}/${{ env.BRANCH_NAME }}:latest"
39+
gh release create "${{ env.BRANCH_NAME }}" --notes "$RELEASE_BODY" || \
40+
gh release edit "${{ env.BRANCH_NAME }}" --notes "$RELEASE_BODY"

0 commit comments

Comments
 (0)