-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
125 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # 当 `main` 分支有 push 时触发 | ||
tags: | ||
- 'v*.*.*' # 当有新的 tag 时触发 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install cosign | ||
if: github.event_name != 'pull_request' | ||
uses: sigstore/cosign-installer@v3.5.0 | ||
with: | ||
cosign-release: 'v2.2.4' | ||
|
||
# 设置 Buildx 以支持多架构构建 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# 登录 GitHub Container Registry | ||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# 提取 Docker 镜像的元数据(标签、名称等) | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=ref,event=branch | ||
type=sha | ||
type=ref,event=tag | ||
# 构建并推送多架构 Docker 镜像 | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6.9.0 | ||
id: build-and-push | ||
with: | ||
context: . | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
# 使用 cosign 签名发布的 Docker 镜像 | ||
- name: Sign the published Docker image | ||
if: ${{ github.event_name != 'pull_request' }} | ||
env: | ||
DIGEST: ${{ steps.build-and-push.outputs.digest }} | ||
TAGS: ${{ steps.meta.outputs.tags }} | ||
run: | | ||
images="" | ||
for tag in $(echo $TAGS | tr ',' '\n'); do | ||
images+="ghcr.io/${{ github.repository }}:$tag@${DIGEST} " | ||
done | ||
cosign sign --yes ${images} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '3.8' | ||
|
||
services: | ||
weibo-album-dl: | ||
image: weibo-album-dl:latest | ||
container_name: weibo-album-dl | ||
restart: unless-stopped | ||
volumes: | ||
- ./dl:/dl # 可选:挂载本地目录到容器中 | ||
environment: | ||
WB_DL_ARGS: "-s /dl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Container] | ||
ContainerName=weibo-album-dl | ||
Environment="WB_DL_ARGS=-s /dl" | ||
Image=weibo-album-dl:latest | ||
Volume=/mnt/sda1/code/dl:/dl | ||
WorkingDir=/app | ||
|
||
[Service] | ||
Restart=always | ||
|
||
[Unit] | ||
Description=weibo-album-dl | ||
After=network.target | ||
|
||
[Install] | ||
WantedBy=multi-user.target |