Skip to content

Commit ebc0d23

Browse files
authored
Fix project sync workflow YAML formatting (#4)
1 parent 4e0c7b0 commit ebc0d23

1 file changed

Lines changed: 64 additions & 1 deletion

File tree

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,64 @@
1-
name: add-to-project # Auto-adds every new issue / PR to the FastLED Tracker project (#1). # # Auth: GitHub App "FastLED Project Sync" — scoped to Projects: read/write + # Contents/Issues/Pull requests: read. No expiration (App installation tokens # auto-rotate). The App ID lives in a repo variable; the private key lives in # a repo secret. # # Required configuration (already set on all 6 feeder repos): # vars.PROJECT_APP_CLIENT_ID = Iv23liL4dLxjYFwTNWKt # vars.PROJECT_OWNER = FastLED # vars.PROJECT_NUMBER = 1 # secrets.PROJECT_APP_PRIVATE_KEY = <PEM contents> # # To rotate the App's private key: # 1. On https://github.com/organizations/FastLED/settings/apps generate new key # 2. For each repo: gh secret set PROJECT_APP_PRIVATE_KEY --repo FastLED/<repo> < new.pem # 3. Revoke the old key in the App settings on: issues: types: [opened] pull_request: types: [opened] env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" # pull_request (not pull_request_target) — fork PRs run in the fork's context # without access to PROJECT_APP_PRIVATE_KEY, so they simply won't be # auto-added. That is an intentional security trade-off: pull_request_target # would run with base-repo secrets against fork-authored metadata, which is a # known exfiltration vector even when no code is checked out. permissions: contents: read pull-requests: read jobs: add: runs-on: ubuntu-latest if: ${{ vars.PROJECT_APP_CLIENT_ID != '' && vars.PROJECT_OWNER != '' }} steps: - name: Generate App token id: app-token continue-on-error: true uses: actions/create-github-app-token@v3 with: client-id: ${{ vars.PROJECT_APP_CLIENT_ID }} private-key: ${{ secrets.PROJECT_APP_PRIVATE_KEY }} owner: ${{ vars.PROJECT_OWNER }} - name: App not installed — skipping project sync if: ${{ steps.app-token.outcome != 'success' }} run: | echo "::warning::FastLED Project Sync App is not installed on '${{ vars.PROJECT_OWNER }}'." echo "::warning::Install it at https://github.com/organizations/${{ vars.PROJECT_OWNER }}/settings/installations to enable auto-add-to-project." - name: Add to project if: ${{ steps.app-token.outcome == 'success' }} uses: actions/add-to-project@v1.0.2 with: project-url: https://github.com/orgs/${{ vars.PROJECT_OWNER }}/projects/${{ vars.PROJECT_NUMBER }} github-token: ${{ steps.app-token.outputs.token }}
1+
name: add-to-project
2+
3+
# Auto-adds every new issue / PR to the FastLED Tracker project (#1).
4+
#
5+
# Auth: GitHub App "FastLED Project Sync" — scoped to Projects: read/write +
6+
# Contents/Issues/Pull requests: read. No expiration (App installation tokens
7+
# auto-rotate). The App ID lives in a repo variable; the private key lives in
8+
# a repo secret.
9+
#
10+
# Required configuration (already set on all 6 feeder repos):
11+
# vars.PROJECT_APP_CLIENT_ID = Iv23liL4dLxjYFwTNWKt
12+
# vars.PROJECT_OWNER = FastLED
13+
# vars.PROJECT_NUMBER = 1
14+
# secrets.PROJECT_APP_PRIVATE_KEY = <PEM contents>
15+
#
16+
# To rotate the App's private key:
17+
# 1. On https://github.com/organizations/FastLED/settings/apps generate new key
18+
# 2. For each repo: gh secret set PROJECT_APP_PRIVATE_KEY --repo FastLED/<repo> < new.pem
19+
# 3. Revoke the old key in the App settings
20+
21+
on:
22+
issues:
23+
types: [opened]
24+
pull_request:
25+
types: [opened]
26+
27+
env:
28+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
29+
30+
# pull_request (not pull_request_target) — fork PRs run in the fork's context
31+
# without access to PROJECT_APP_PRIVATE_KEY, so they simply won't be
32+
# auto-added. That is an intentional security trade-off: pull_request_target
33+
# would run with base-repo secrets against fork-authored metadata, which is a
34+
# known exfiltration vector even when no code is checked out.
35+
permissions:
36+
contents: read
37+
pull-requests: read
38+
39+
jobs:
40+
add:
41+
runs-on: ubuntu-latest
42+
if: ${{ vars.PROJECT_APP_CLIENT_ID != '' && vars.PROJECT_OWNER != '' }}
43+
steps:
44+
- name: Generate App token
45+
id: app-token
46+
continue-on-error: true
47+
uses: actions/create-github-app-token@v3
48+
with:
49+
client-id: ${{ vars.PROJECT_APP_CLIENT_ID }}
50+
private-key: ${{ secrets.PROJECT_APP_PRIVATE_KEY }}
51+
owner: ${{ vars.PROJECT_OWNER }}
52+
53+
- name: App not installed — skipping project sync
54+
if: ${{ steps.app-token.outcome != 'success' }}
55+
run: |
56+
echo "::warning::FastLED Project Sync App is not installed on '${{ vars.PROJECT_OWNER }}'."
57+
echo "::warning::Install it at https://github.com/organizations/${{ vars.PROJECT_OWNER }}/settings/installations to enable auto-add-to-project."
58+
59+
- name: Add to project
60+
if: ${{ steps.app-token.outcome == 'success' }}
61+
uses: actions/add-to-project@v1.0.2
62+
with:
63+
project-url: https://github.com/orgs/${{ vars.PROJECT_OWNER }}/projects/${{ vars.PROJECT_NUMBER }}
64+
github-token: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)