Skip to content

Commit

Permalink
feat: publish-release.yml新增手动输入tag功能
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Mar 20, 2022
1 parent 0283b8c commit bde4ceb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
43 changes: 35 additions & 8 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Publish image

on:
workflow_dispatch:
inputs:
manualTag:
description: 'tag'
required: true
release:
types: [published]

Expand All @@ -26,17 +30,35 @@ jobs:
- name: Check the value
run: |
echo ${{ steps.step_one.outputs.hasToken }}
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_REF#refs/tags/: ${GITHUB_REF#refs/tags/}"
##echo "GITHUB_REF: $GITHUB_REF"
##echo "GITHUB_REF#refs/tags/: ${GITHUB_REF#refs/tags/}"
echo "github.event.release.tag_name: ${{ github.event.release.tag_name }}"
echo "github.event.inputs.manualTag: ${{ github.event.inputs.manualTag }}"
Publish2DockerHub:
runs-on: ubuntu-latest
needs: CheckDockerToken
if: "contains(needs.CheckDockerToken.outputs.hasToken, 'true')"
steps:
-
name: GetRepoTag
id: getRepoTag
run: |
RepoTag=""
if [ "${{ github.event.release.tag_name }}" ] ; then
RepoTag=${{ github.event.release.tag_name }}
fi
if [ "${{ github.event.inputs.manualTag }}" ] ; then
RepoTag=${{ github.event.inputs.manualTag }}
fi
echo "repo tag: $RepoTag"
echo "::set-output name=repoTag::$RepoTag"
-
name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ steps.getRepoTag.outputs.repoTag }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
Expand All @@ -50,17 +72,22 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: GetTagName
id: getTag
name: GetDockerTagNames
id: getDockerTags
run: |
DOCKER_IMAGE_TAG="zai7lou/bilibili_tool_pro:${GITHUB_REF#refs/tags/},zai7lou/bilibili_tool_pro:latest"
echo "docker image tag: $DOCKER_IMAGE_TAG"
echo "::set-output name=tag::$DOCKER_IMAGE_TAG"
DOCKER_IMAGE_TAG="zai7lou/bilibili_tool_pro:${{ steps.getRepoTag.outputs.repoTag }},zai7lou/bilibili_tool_pro:latest"
DOCKER_IMAGE_LATEST_TAG=",zai7lou/bilibili_tool_pro:latest"
if [ "${{ github.event.inputs.manualTag }}" ] ; then
DOCKER_IMAGE_LATEST_TAG=""
fi
DOCKER_IMAGE_TAGS=$DOCKER_IMAGE_TAG$DOCKER_IMAGE_LATEST_TAG
echo "docker image tag: $DOCKER_IMAGE_TAGS"
echo "::set-output name=dockerTags::$DOCKER_IMAGE_TAGS"
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.getTag.outputs.tag }}
tags: ${{ steps.getDockerTags.outputs.dockerTags }}
4 changes: 3 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.version }}

- name: Setup .NET
uses: actions/setup-dotnet@v1
Expand Down Expand Up @@ -51,7 +53,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
release_name: BiliBiliTool-V${{ github.event.inputs.version }}
release_name: BiliBiliToolPro-V${{ github.event.inputs.version }}
draft: true
prerelease: false

Expand Down

0 comments on commit bde4ceb

Please sign in to comment.