Skip to content

GitHub Readme YouTube Cards

在你的 readme 中显示最近的 YouTube 视频作为 SVG 卡片。

ref-reporef-official-docref-dependent-action

用法

  1. 将以下代码片段添加到您想显示卡片的地方的 markdown 文件中。
yaml
<!-- BEGIN YOUTUBE-CARDS -->
<!-- END YOUTUBE-CARDS -->
  1. 在你的仓库中,创建一个名为 .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

点击显示/关闭参数

名称类型必填默认值参数描述更多描述
ref-actions
channel_idstringtrue你的 YouTube channel ID
playlist_idstring播放列表 ID
langstringen语言
comment_tag_namestringYOUTUBE-CARDS注释标签中替换内容的文本
youtube_api_keystringYouTube API 密钥
max_videosnumber6显示的视频最大数量
base_urlstringhttps://ytcards.demolab.com/卡片的基础 URL
card_widthnumber250卡片的宽度单位:像素。
border_radiusnumber5卡片的圆角半径
background_colorstring#0d1117卡片的背景颜色
title_colorstring#ffffff卡片的标题颜色
stats_colorstring#dedede统计文本的颜色
theme_context_lightany{}浅色模式颜色JSON对象
theme_context_darkany{}深色模式颜色JSON对象
max_title_linesnumber1标题的最大行数
show_durationbooleanfalse是否显示视频时长依赖于 YouTube API 密钥 youtube_api_key
author_namestringGitHub Actions提交者的名字
author_emailstring41898282+github-actions[bot]@users.noreply.github.com提交作者的电子邮件地址
commit_messagestringdocs(readme): Update YouTube cards提交信息
readme_pathstringREADME.mdMarkdown 或 HTML 文件的路径
output_onlybooleanfalse是否跳过写入到 README 文件
output_typestringmarkdown输出类型可选值:markdown html
ref-action-outputs
markdownstringtrue生成的 Markdown 或 HTML 用于更新 README 文件
committedstringtrue是否动作已创建提交可能值:true false
commit_long_shastringtrue刚刚创建的提交的完整 SHA 值
commit_shastringtrue刚刚创建的提交的 7 位短 SHA 值
pushedstringtrue是否动作已推送到远程可能值: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
GitHub Star Swag Unboxing and GiveawaysHow To Self-Host GitHub Readme Streak Stats on VercelAutomatically Deploy to Fly.io with GitHub ActionsHosting a Python Discord Bot for Free with Fly.ioMaking a Wordle Clone Discord Bot with Python (Nextcord)Run Open Source Code in Seconds with GitPod

Readme Widget Hub (v4.1.4) MIT Licensed