GitHub Readme YouTube Cards
在你的 readme 中显示最近的 YouTube 视频作为 SVG 卡片。
用法
- 将以下代码片段添加到您想显示卡片的地方的 markdown 文件中。
yaml
<!-- BEGIN YOUTUBE-CARDS -->
<!-- END YOUTUBE-CARDS -->
- 在你的仓库中,创建一个名为
.github
的文件夹,然后在其中创建一个名为workflows
的文件夹(如果不存在的话)。接着在.github/workflows/
文件夹中创建一个文件,并给它命名为youtube-cards.yml
,内容如下。
yaml
name: GitHub Readme YouTube Cards
on:
schedule:
# 每小时整点运行
- cron: "0 * * * *"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
# 允许 GitHub Actions 写入仓库
permissions:
contents: write
# 运行 GitHub Readme YouTube Cards 动作
steps:
- uses: DenverCoder1/github-readme-youtube-cards@main
with:
# 你的 YouTube 频道 ID
channel_id: UCipSxT7a3rn81vGLw9lqRkg
参数
DenverCoder1/github-readme-youtube-cards@main
点击显示/关闭参数
名称 | 类型 | 必填 | 默认值 | 参数描述 | 更多描述 |
---|---|---|---|---|---|
channel_id | string | true | 你的 YouTube channel ID | ||
playlist_id | string | 播放列表 ID | |||
lang | string | en | 语言 | ||
comment_tag_name | string | YOUTUBE-CARDS | 注释标签中替换内容的文本 | ||
youtube_api_key | string | YouTube API 密钥 | |||
max_videos | number | 6 | 显示的视频最大数量 | ||
base_url | string | https://ytcards.demolab.com/ | 卡片的基础 URL | ||
card_width | number | 250 | 卡片的宽度 | 单位:像素。 | |
border_radius | number | 5 | 卡片的圆角半径 | ||
background_color | string | #0d1117 | 卡片的背景颜色 | ||
title_color | string | #ffffff | 卡片的标题颜色 | ||
stats_color | string | #dedede | 统计文本的颜色 | ||
theme_context_light | any | {} | 浅色模式颜色JSON对象 | ||
theme_context_dark | any | {} | 深色模式颜色JSON对象 | ||
max_title_lines | number | 1 | 标题的最大行数 | ||
show_duration | boolean | false | 是否显示视频时长 | 依赖于 YouTube API 密钥 youtube_api_key 。 | |
author_name | string | GitHub Actions | 提交者的名字 | ||
author_email | string | 41898282+github-actions[bot]@users.noreply.github.com | 提交作者的电子邮件地址 | ||
commit_message | string | docs(readme): Update YouTube cards | 提交信息 | ||
readme_path | string | README.md | Markdown 或 HTML 文件的路径 | ||
output_only | boolean | false | 是否跳过写入到 README 文件 | ||
output_type | string | markdown | 输出类型 | 可选值:markdown html 。 | |
markdown | string | true | 生成的 Markdown 或 HTML 用于更新 README 文件 | ||
committed | string | true | 是否动作已创建提交 | 可能值:true false 。 | |
commit_long_sha | string | true | 刚刚创建的提交的完整 SHA 值 | ||
commit_sha | string | true | 刚刚创建的提交的 7 位短 SHA 值 | ||
pushed | string | true | 是否动作已推送到远程 | 可能值:true false 。 |
示例
yaml
# Example usage: https://github.com/DenverCoder1/github-readme-youtube-cards/blob/main/.github/workflows/youtube-cards.yml
name: GitHub Readme YouTube Cards
on:
schedule:
# Runs every day at 12:00
- cron: "0 12 * * *"
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: DenverCoder1/github-readme-youtube-cards@main
id: youtube-cards
with:
channel_id: UCipSxT7a3rn81vGLw9lqRkg
comment_tag_name: EXAMPLE-YOUTUBE-CARDS
youtube_api_key: ${{ secrets.YOUTUBE_API_KEY }}
show_duration: true
theme_context_light: '{ "background_color": "#ffffff", "title_color": "#24292f", "stats_color": "#57606a" }'
theme_context_dark: '{ "background_color": "#0d1117", "title_color": "#ffffff", "stats_color": "#dedede" }'
max_title_lines: 2
output_type: html
- run: echo OUTPUT '${{ steps.youtube-cards.outputs.markdown }}'
shell: bash