---
title: "Automatically Rotating GitHub Tokens (So You Don’t Have To)"
description: "Shopify replaced long-lived GitHub personal access tokens with short-lived GitHub App installation tokens that are rotated automatically by scheduled GitHub Actions workflows and written into repository secrets."
url: "https://swe.quest/articles/automatically-rotating-github-tokens-so-you-don-t-have-to-45a6ed60a4bb7896"
canonical: "https://shopify.engineering/automatically-rotate-github-tokens"
source: "Shopify Engineering"
published: "2022-12-20"
difficulty: "medium"
kind: "Case study"
reading_minutes: 11
tags: ["identity-auth","ci-cd","security","developer-tools"]
---

# Automatically Rotating GitHub Tokens (So You Don’t Have To)

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2022-12-20, 11 min read, Case study. Original: [https://shopify.engineering/automatically-rotate-github-tokens](https://shopify.engineering/automatically-rotate-github-tokens)

## Summary

Shopify replaced long-lived GitHub personal access tokens with short-lived GitHub App installation tokens that are rotated automatically by scheduled GitHub Actions workflows and written into repository secrets. Developers can reference those secrets exactly as they did PATs. The design avoids breakage from developer churn and misattribution of actions, and shrinks the blast radius of leaked tokens. Lessons learned: billable minutes are rounded per job, so parallel jobs were consolidated into one sequential job. The cron \`schedule\` trigger is best-effort, so it moved to explicit minute-of-hour runs every 15 minutes to stay within the one-hour token expiry. Onboarding evolved into a plop.js wizard with use-case-based permission selection, and a step-by-step recipe for building the rotator closes out the write-up.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [Security](https://swe.quest/tags/security.md) (Security)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)

## Prerequisites

- GitHub Actions workflows ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))
- GitHub Apps
- personal access tokens

## Keywords

GitHub Actions, GitHub Apps, personal access tokens, GITHUB\_TOKEN, plop.js, workflow\_dispatch

## Related posts

- [Incident Report: January 28-29, 2026](https://swe.quest/articles/incident-report-january-28-29-2026-596231b4a4df80f7.md): Railway · 2026-01-26 · Medium · 4 min read · Incidents & postmortems, Identity & auth, Caching, API design
  Railway users intermittently could not log in with GitHub or deploy from repos over several days because Railway exceeded GitHub's 2,000-per-hour OAuth token limit, with failures recurring about 30 minutes into each hour.
- [Security Disclosure Recommendation: Check for Anomalous GitHub Access](https://swe.quest/articles/security-disclosure-recommendation-check-for-anomalous-github-access-acf8b4a01ac2abcd.md): Railway · 2026-10-22 · Medium · 1 min read · Identity & auth, Incidents & postmortems, Security
  Railway users who connect GitHub, following the October 21, 2026 security disclosure, should audit their GitHub accounts for persistence an attacker may have left behind, then confirm no unexpected commits reached their deployments.
- [Staying Evergreen: How we automated secure access and repo hygiene in a shared org](https://swe.quest/articles/staying-evergreen-how-we-automated-secure-access-and-repo-hygiene-in-a-shared-b76aa86640c047a2.md): GitHub Engineering · 2026-10-15 · Medium · 8 min read · Identity & auth, Developer tools, Security, System design
  Evergreen is a Go-based GitHub App that automates quarterly outside-collaborator access reviews and stale-repo archival in a shared org of 1,400+ GitHub employees, customers and partners, built entirely from native primitives: scheduled Actions firing repository\_dispatch, webhooks, issue checklists, custom properties, and per-repo JSON state files in git that double as the audit trail.
- [Using GitHub Actions with Heroku Flow for additional Security Control](https://swe.quest/articles/using-github-actions-with-heroku-flow-for-additional-security-control-fea72ed977a6f5e4.md): Heroku Engineering · 2025-03-27 · Medium · 7 min read · CI/CD, Deployment, Security, Cloud platforms
  Because GitHub Orgs can't allowlist Heroku IP ranges, Heroku offers a sample pattern: a self-hosted GitHub Actions runner deployed as a Docker app in a Heroku Private Space with static outbound IPs, plus a Heroku Flow Action.
- [Our response to the Axios developer tool compromise](https://swe.quest/articles/our-response-to-the-axios-developer-tool-compromise-1553cdb638ce1a6b.md): OpenAI · 2026-04-10 · Medium · 5 min read · Supply chain security, CI/CD, Incidents & postmortems, JavaScript
  A GitHub Actions workflow in OpenAI's macOS app-signing pipeline downloaded and executed a malicious Axios 1.14.1 during the March 31, 2026 npm supply chain attack, exposing the code-signing certificate and notarization material for ChatGPT Desktop, Codex, Codex CLI and Atlas.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
