October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
DocumentaryTube
GitHub Actions

How to Schedule Recurring YouTube Playlist Rotations with GitHub Actions

A practical guide to scheduling YouTube playlist rotations with GitHub Actions, including cron timing, OAuth secrets, idempotent API changes, and troubleshooting.

By DocumentaryTube Team 6 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a scheduled GitHub Actions workflow to compare a configured list of video IDs with the current YouTube playlist, then insert missing videos and remove unwanted entries. The workflow needs OAuth authorization for playlist changes; a YouTube API key alone is not enough. Because scheduled runs can be delayed or dropped, make the workflow safe to rerun and include a manual recovery path.

How the rotation works

Keep the target playlist ID, desired video IDs in order, and retention policy in the repository. A workflow in .github/workflows/ runs on a cron schedule, reads the playlist, compares its current state with the configured state, and applies only the necessary changes.

YouTube represents each playlist entry as a playlistItem. An entry has its own playlist-item id as well as the underlying video’s ID in snippet.resourceId.videoId. Use the video ID to decide which videos belong in the playlist; use the playlist-item ID when deleting a particular entry. See Google’s playlist item resource.

Set up the scheduled workflow

Choose a cadence and timezone

GitHub Actions uses POSIX cron syntax for scheduled workflows, with a documented minimum interval of five minutes. Schedules run in UTC unless you specify an IANA timezone. A scheduled workflow runs against the latest commit on the repository’s default branch, so changes to the workflow or rotation configuration must reach that branch to affect scheduled runs. See GitHub’s schedule event documentation and workflow syntax.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

For a fixed UTC cadence, leave the timezone unspecified and express the cron time in UTC. For a local wall-clock cadence, specify an IANA timezone; during a spring-forward skipped hour, GitHub advances the run to the next valid time. Avoid scheduling at the top of the hour where practical. GitHub warns that high load can delay scheduled events and that queued runs can be dropped, particularly around busy times. The documented five-minute minimum does not mean a run will start at an exact minute.

Add a workflow file

Create a file such as .github/workflows/playlist-rotation.yml. This is a skeleton: replace the example schedule and script path with the cadence and implementation you intend to use. Add a workflow_dispatch trigger so you can test or recover a run manually.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
name: Rotate YouTube playlist

on:
  schedule:
    - cron: '17 12 * * *'
  workflow_dispatch:

permissions:
  contents: read

jobs:
  rotate:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
      - name: Rotate playlist
        env:
          YOUTUBE_OAUTH_CREDENTIALS: ${{ secrets.YOUTUBE_OAUTH_CREDENTIALS }}
        run: python scripts/rotate_playlist.py

The example cron expression means 12:17 UTC daily when no timezone is specified. The workflow alone does not implement playlist changes: scripts/rotate_playlist.py must authenticate to YouTube and perform the list, comparison, insertion, deletion, and any required ordering operations. Keep the OAuth secret mapped only into the step that needs it.

Authorize playlist changes securely

YouTube playlist writes require an OAuth authorization token with a supported YouTube scope. The insert and delete API references list scopes including https://www.googleapis.com/auth/youtube and https://www.googleapis.com/auth/youtube.force-ssl. An API key is not sufficient for changing a playlist. See Google’s insert, delete, and API authentication documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
  1. Set up an OAuth client and a refresh-token strategy for the Google account that owns or can edit the channel’s playlist. The consent and credential lifecycle requires Google-side setup; do not assume an unattended refresh token exists automatically.
  2. Store the credential material in GitHub Actions secrets, either as a repository secret or an environment secret. Environment secrets can be guarded with required reviewers; choose the narrowest scope and approval process suitable for the channel.
  3. Pass the secret to only the workflow step that uses it. Never print credentials, access tokens, or transformed values derived from them in logs.
  4. Keep the workflow’s GITHUB_TOKEN permissions minimal. Repository access and YouTube OAuth are separate: a read-only repository token does not authorize playlist changes.

GitHub’s guidance covers using secrets and security hardening.

Reconcile the playlist without creating duplicates

Use a read-compare-reconcile process rather than blindly adding every configured video on every run. YouTube’s list, insert, delete, and update methods provide the operations; the reconciliation logic is your implementation responsibility.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2Ă— USB C male to USB A female adapters and 2Ă— USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  1. Load desired state. Read the playlist ID, ordered video IDs, and retention policy from version-controlled configuration. Validate that IDs are present and that the desired list does not contain accidental duplicates.
  2. List current entries. Retrieve playlist items and retain each entry’s playlist-item ID, video ID, and position. Handle pagination so the comparison covers the full playlist.
  3. Compute the difference. Identify desired videos that are missing and current entries that the retention policy says to remove. Decide explicitly whether videos not listed in configuration should be preserved or deleted.
  4. Insert only missing videos. The insert request requires the target playlist ID and a resource identifying the video. Confirm the intended playlist and video before writing.
  5. Delete only confirmed unwanted entries. Re-list or otherwise confirm state before destructive changes, then call delete using the playlist-item ID—not the underlying video ID.
  6. Set order if needed. If the playlist must match a configured order, use the update operation to change positions. Verify the result by listing the playlist again.
  7. Report the outcome. Log a concise summary of added, removed, reordered, and unchanged entries without logging credentials.

A rerun should converge on the same intended playlist, not add duplicates or remove entries based on stale state. The YouTube API documentation provides the operations but does not prescribe a rotation algorithm; define the policy that suits your channel before enabling destructive changes.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Plan for missed runs and API limits

Scheduled workflows are best-effort, not a minute-exact scheduler. GitHub documents that scheduled events may be delayed during high load and queued runs may be dropped. For public repositories, scheduled workflows are automatically disabled after 60 days without repository activity. Keep a visible run summary, monitor failures, and use the manual trigger to recover after a missed run. If rotation timing is business-critical, consider a scheduler with stronger delivery guarantees.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Google’s API reference lists these quota costs: playlist-item list costs 1 unit per call, while insert and delete each cost 50 units per call. The pages do not state a publication year. A read-and-diff approach avoids unnecessary writes; check your project’s current quota allocation and limits in Google’s project console. See list, insert, and delete.

Writes can fail when authorization is missing or inadequate, a video is inaccessible, a playlist has reached its item limit, an item is duplicated, or the playlist does not support the requested operation. Some special or system playlists may not support changes. Treat API errors as actionable failures; do not report a successful rotation merely because the workflow started.

Troubleshoot common failures

Symptom Likely cause What to check
The workflow does not run on schedule The workflow change is not on the default branch, the cron expression or timezone is wrong, or a public repository has had no activity for 60 days. Confirm the workflow is on the default branch, validate the schedule and timezone, and check repository activity. Use workflow_dispatch to test or recover.
The run starts late or is absent Scheduled events can be delayed under load, and queued runs can be dropped. Do not rely on exact-minute delivery. Inspect the Actions run history, then dispatch a recovery run if needed.
YouTube returns an authorization error The step lacks a valid OAuth token, the token lacks a supported scope, or the credential refresh setup is incomplete. Check the channel owner’s OAuth setup and requested scopes. Confirm the secret is available to the job without printing it.
Deletion fails or removes the wrong entry The request used the video ID instead of the playlist-item ID, or the playlist state changed after it was read. Fetch current items again, map each video ID to its playlist-item ID, and delete only the confirmed entry.
An insert is rejected The video may be inaccessible, duplicated, or the playlist may be full or unsupported. Check the API error details and playlist type, then adjust configuration or permissions rather than retrying the same write indefinitely.
The final order is wrong Insertion order alone may not match the desired playlist order. Use playlist-item updates for positions, then list the playlist again to verify the result.

Or let it run in the cloud

GitHub Actions automates playlist changes; it does not keep a YouTube live stream running. If your goal is to broadcast uploaded videos as a continuous YouTube stream, StreamNeo is a separate cloud option: upload a recording or build a playlist, add your YouTube stream key once, and go live. It loops uploaded videos from the cloud, so nothing has to stay on at home. It streams the upload as made, up to 4K 60fps, at one price per slot; it automatically recovers if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month.

Start your free StreamNeo day.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Screening Room

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.