mirror of
https://github.com/nickrunning/wechat-selkies.git
synced 2026-05-09 00:24:09 +00:00
ci: add push to docker hub support
This commit is contained in:
42
.github/workflows/docker.yml
vendored
42
.github/workflows/docker.yml
vendored
@@ -8,11 +8,13 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
|
DOCKERHUB_REGISTRY: docker.io
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-publish:
|
build-and-publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
environment: DOCKERHUB
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
@@ -27,23 +29,34 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract metadata
|
- name: Login to Docker Hub
|
||||||
|
if: vars.ENABLE_DOCKERHUB == 'true'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.DOCKERHUB_REGISTRY }}
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: |
|
||||||
|
ghcr.io/${{ github.repository }}
|
||||||
|
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }},enable=${{ vars.ENABLE_DOCKERHUB == 'true' }}
|
||||||
|
flavor: |
|
||||||
|
latest=false
|
||||||
tags: |
|
tags: |
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
type=raw,value=latest
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') || startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
id: build-image
|
id: build-image
|
||||||
@@ -67,11 +80,28 @@ jobs:
|
|||||||
|
|
||||||
- name: Output Docker image information
|
- name: Output Docker image information
|
||||||
run: |
|
run: |
|
||||||
echo "## 🐳 Docker Image Published" >> $GITHUB_STEP_SUMMARY
|
echo "## 🐳 Docker Images Published" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "### GitHub Container Registry" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Registry:** ${{ env.REGISTRY }}" >> $GITHUB_STEP_SUMMARY
|
echo "**Registry:** ${{ env.REGISTRY }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Repository:** ${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY
|
echo "**Repository:** ${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Digest:** \`${{ steps.build-image.outputs.digest }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "**Digest:** \`${{ steps.build-image.outputs.digest }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
|
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
|
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
if [ "${{ vars.ENABLE_DOCKERHUB }}" == "true" ]; then
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "### Docker Hub" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Registry:** ${{ env.DOCKERHUB_REGISTRY }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Repository:** ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Digest:** \`${{ steps.build-image.outputs.digest }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "### Docker Hub" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "⚠️ **Skipped** - Docker Hub push disabled (set ENABLE_DOCKERHUB=true to enable)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
12
README.md
12
README.md
@@ -62,7 +62,17 @@ docker run -it -p 3001:3001 -v ./config:/config ghcr.io/nickrunning/wechat-selki
|
|||||||
|
|
||||||
### 配置说明
|
### 配置说明
|
||||||
|
|
||||||
更多自定义配置请参考 [Selkies Base Images from LinuxServer](https://github.com/linuxserver/docker-baseimage-selkies).
|
更多自定义配置请参考 [Selkies Base Images from LinuxServer](https://github.com/linuxserver/docker-baseimage-selkies)。
|
||||||
|
|
||||||
|
#### Docker Hub 推送配置
|
||||||
|
|
||||||
|
本项目支持同时推送到 GitHub Container Registry 和 Docker Hub。如需启用 Docker Hub 推送功能,请在仓库下添加Environment Secrets和Environment Variables:
|
||||||
|
|
||||||
|
**必需的Environment Secrets:**
|
||||||
|
* DOCKERHUB_USERNAME: 你的 Docker Hub 用户名
|
||||||
|
* DOCKERHUB_TOKEN: 你的 Docker Hub Access Token
|
||||||
|
**必需的Environment Variables:**
|
||||||
|
* ENABLE_DOCKERHUB: 设置为 `true` 来启用 Docker Hub 推送
|
||||||
|
|
||||||
#### 环境变量配置
|
#### 环境变量配置
|
||||||
|
|
||||||
|
|||||||
10
README_en.md
10
README_en.md
@@ -64,6 +64,16 @@ docker run -it -p 3001:3001 -v ./config:/config ghcr.io/nickrunning/wechat-selki
|
|||||||
|
|
||||||
For more custom configurations, please refer to [Selkies Base Images from LinuxServer](https://github.com/linuxserver/docker-baseimage-selkies).
|
For more custom configurations, please refer to [Selkies Base Images from LinuxServer](https://github.com/linuxserver/docker-baseimage-selkies).
|
||||||
|
|
||||||
|
#### Docker Hub Push Configuration
|
||||||
|
This project supports pushing to both GitHub Container Registry and Docker Hub. Docker Hub push is optional and requires manual configuration. Please add the following Environment Secrets and Environment Variables in your repository to enable Docker Hub push functionality:
|
||||||
|
|
||||||
|
**Required Environment Secrets:**
|
||||||
|
* `DOCKERHUB_USERNAME`: Your Docker Hub username
|
||||||
|
* `DOCKERHUB_TOKEN`: Your Docker Hub Access Token
|
||||||
|
|
||||||
|
**Required Environment Variables:**
|
||||||
|
* `ENABLE_DOCKERHUB`: Set to `true` to enable Docker Hub push
|
||||||
|
|
||||||
#### Environment Variables
|
#### Environment Variables
|
||||||
|
|
||||||
Configure the following environment variables in `docker-compose.yml`:
|
Configure the following environment variables in `docker-compose.yml`:
|
||||||
|
|||||||
Reference in New Issue
Block a user