Repository navigation
Expand file tree
/
Copy pathgithub-pat.yml
More file actions
104 lines (97 loc) · 3.1 KB
/
Copy pathgithub-pat.yml
File metadata and controls
104 lines (97 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# yaml-language-server: $schema=https://github.com/zloeber/SecretZero/raw/refs/heads/main/Secretfile.schema.json
#
# Example: Generate a scoped GitHub App installation token (fine-grained PAT
# equivalent) with specific permissions declared in the manifest.
#
# Prerequisites:
# 1. A GitHub App must be registered with the desired permission set.
# 2. The App must be installed on the target organization/repository.
# 3. Set environment variables (or provide via provider config):
# GITHUB_APP_ID – numeric App ID
# GITHUB_APP_PRIVATE_KEY – PEM-encoded App private key
# GITHUB_APP_INSTALLATION_ID – numeric installation ID
# GITHUB_TOKEN – classic PAT for storing the resulting token
#
# How it works:
# SecretZero mints a short-lived JWT from the App credentials, then calls
# POST /app/installations/{id}/access_tokens with only the permissions
# listed below. The resulting token is stored in the configured targets.
variables:
github_org: my-org
github_repo: my-service
providers:
github:
kind: github
auth:
kind: token
config:
token: ${GITHUB_TOKEN}
config:
# GitHub App credentials for PAT generation
app_id: ${GITHUB_APP_ID}
private_key: ${GITHUB_APP_PRIVATE_KEY}
installation_id: ${GITHUB_APP_INSTALLATION_ID}
secrets:
# ── CI deploy token with read-only access ──────────────────────────
- name: ci_deploy_token
kind: github_pat
config:
provider: github
permissions:
contents: read
metadata: read
actions: read
repositories:
- my-service
token_name: ci-deploy-readonly
expires_in_hours: 1
targets:
- provider: github
kind: github_secret
config:
owner: ${github_org}
repo: ${github_repo}
secret_name: CI_DEPLOY_TOKEN
# ── Release token with write access to contents & PRs ──────────────
- name: release_token
kind: github_pat
config:
provider: github
permissions:
contents: write
pull_requests: write
issues: write
workflows: write
repositories:
- my-service
token_name: release-bot
targets:
- provider: github
kind: github_secret
config:
owner: ${github_org}
repo: ${github_repo}
secret_name: RELEASE_TOKEN
# ── Broad org-level admin token (no repository scoping) ────────────
- name: org_admin_token
kind: github_pat
config:
provider: github
permissions:
organization_administration: write
members: read
token_name: org-admin
targets:
- provider: github
kind: github_secret
config:
owner: ${github_org}
repo: ${github_repo}
secret_name: ORG_ADMIN_TOKEN
metadata:
project: github-pat-example
owner: platform-team
description: Demonstrates scoped GitHub PAT generation via GitHub App tokens
environments:
- ci
- production