Skip to content

Setting Up the Action with a YouTube API Key

Jonah Lawrence edited this page Oct 19, 2022 · 4 revisions

Some features of YouTube Cards require an API key.

Below you will find the steps to obtain an API key, add it as a repository secret, and use it in a GitHub action.

Obtaining a YouTube API Key

  1. Go to https://console.developers.google.com/project and sign in
  2. Click "Create Project"
  3. Name your project and click "Create"
  4. Click the "APIs & Services" link from the top-left navigation menu and select your project
  5. Click "Enable APIs and Services"
  6. Search for "YouTube Data API"
  7. Enable "YouTube Data API v3"
  8. In the left panel select "Credentials"
  9. Click "Create Credentials", then "API key"
  10. Copy your API key

Adding a secret to your GitHub Repository

  1. Navigate to your GitHub repository and head to the Settings page

image

  1. In the sidebar, select Secrets > Actions in the Security section

image

  1. Click the New repository secret button to create a new repository secret

image

  1. Enter YOUTUBE_API_KEY as the name, and your key as secret

image

  1. Click Add Secret and it should now appear under your repository secrets

image

Using your API key in an action

To access your secret, use ${{ secrets.YOUTUBE_API_KEY }} in your GitHub action.

Example:

steps:
  - uses: DenverCoder1/github-readme-youtube-cards@main
    with:
      channel_id: UCipSxT7a3rn81vGLw9lqRkg
      comment_tag_name: YOUTUBE-CARDS
      youtube_api_key: ${{ secrets.YOUTUBE_API_KEY }}
      show_duration: true