pull file
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled
This commit is contained in:
87
.github/workflows/publish-image.yml
vendored
Normal file
87
.github/workflows/publish-image.yml
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
name: Publish image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
autoWithLatestTag:
|
||||
description: 'Auto Add Latest Tag'
|
||||
required: true
|
||||
default: true
|
||||
type: boolean
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
env:
|
||||
DOCKERHUB_USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_PASSWORD : ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
GHCR_USERNAME: ${{ github.repository_owner }}
|
||||
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||
DOCKER_IMG_NAME: "zai7lou/bili_tool_web"
|
||||
GHC_IMG_NAME: "ghcr.io/raywangqvq/bili_tool_web"
|
||||
|
||||
jobs:
|
||||
PublishImage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: GetTargetVersion
|
||||
id: getTargetVersion
|
||||
run: |
|
||||
TargetVersion=""
|
||||
if [ "${{ github.event.release.tag_name }}" ] ; then
|
||||
TargetVersion=${{ github.event.release.tag_name }}
|
||||
else
|
||||
TargetVersion=$(grep -oP '(?<=<Version>).*?(?=<\/Version>)' ./common.props)
|
||||
fi
|
||||
echo "TargetVersion: $TargetVersion"
|
||||
echo "TargetVersion=$TargetVersion" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USERNAME }}
|
||||
password: ${{ env.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Log in to ghcr
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ env.GHCR_USERNAME }}
|
||||
password: ${{ env.GHCR_PASSWORD }}
|
||||
|
||||
- name: Generate tags
|
||||
id: tags
|
||||
run: |
|
||||
targetVersion="${{ steps.getTargetVersion.outputs.TargetVersion }}"
|
||||
dockerTagWithVersion="${{ env.DOCKER_IMG_NAME }}:$targetVersion"
|
||||
ghcrTagWithVersion="${{ env.GHC_IMG_NAME }}:$targetVersion"
|
||||
dockerTagWithLatest=""
|
||||
ghcrTagWithLatest=""
|
||||
if [ "${{ github.event.inputs.autoWithLatestTag }}" == "true" ] || [ ${{ github.event.release.created_at }} ]; then
|
||||
dockerTagWithLatest="${{ env.DOCKER_IMG_NAME }}:latest"
|
||||
ghcrTagWithLatest="${{ env.GHC_IMG_NAME }}:latest"
|
||||
fi
|
||||
echo "dockerTagWithVersion=$dockerTagWithVersion" >> $GITHUB_OUTPUT
|
||||
echo "ghcrTagWithVersion=$ghcrTagWithVersion" >> $GITHUB_OUTPUT
|
||||
echo "dockerTagWithLatest=$dockerTagWithLatest" >> $GITHUB_OUTPUT
|
||||
echo "ghcrTagWithLatest=$ghcrTagWithLatest" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
${{ steps.tags.outputs.dockerTagWithVersion }}
|
||||
${{ steps.tags.outputs.ghcrTagWithVersion }}
|
||||
${{ steps.tags.outputs.dockerTagWithLatest }}
|
||||
${{ steps.tags.outputs.ghcrTagWithLatest }}
|
||||
Reference in New Issue
Block a user