Skip to content

GITHUB SECRETS MIGRATION: migrate writer/writer-framework to Infisical - #1290

Open
giusepperrr wants to merge 1 commit into
devfrom
seclift/infisical-github-actions-20260626-153312-r1
Open

GITHUB SECRETS MIGRATION: migrate writer/writer-framework to Infisical#1290
giusepperrr wants to merge 1 commit into
devfrom
seclift/infisical-github-actions-20260626-153312-r1

Conversation

@giusepperrr

@giusepperrr giusepperrr commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Automated Infisical migration PR (orchestrator opened after verifier gate).


Harness contract: composite-v2, centralized composite cf0625c0cb66 (v2.3.0). If the composite SHA has advanced past this, this PR may be drifted — re-verify against the current contract before merge.

Summary by CodeRabbit

  • Security & Permissions
    • Updated workflow permissions and secret handling for safer automated releases.
    • Switched several publish and trigger steps to use environment-based values instead of direct secret references.
  • Bug Fixes
    • Improved version selection logic so release version input is handled more reliably.
    • Updated workflow dispatch behavior to pass event details consistently through job variables.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR updates two GitHub Actions workflows to fetch secrets through Infisical, adds explicit workflow permissions, and switches publish and dispatch steps to use environment-backed values instead of direct secret references.

Changes

Workflow secret sourcing and dispatch

Layer / File(s) Summary
Publish secret sourcing
.github/workflows/publish.yml
jobs.build adds contents: write and id-token: write permissions, Infisical supplies LaunchDarkly and PyPI tokens, and the version and publish steps read those values from environment variables.
Agent-manager dispatch flow
.github/workflows/publish.yml, .github/workflows/trigger-workflow.yml
trigger-agent-manager passes Infisical identity and project secrets into the called workflow, which updates its workflow_call contract, fetches AGENT_MANAGER_PAT from Infisical, and uses it for the dispatch request.

Sequence Diagram(s)

sequenceDiagram
  participant PublishJob as publish.yml trigger-agent-manager job
  participant TriggerWorkflow as trigger-workflow.yml trigger agent manager job
  participant Infisical as Infisical
  participant GitHubAPI as GitHub dispatches API
  PublishJob->>TriggerWorkflow: calls workflow with INFISICAL_* secrets
  TriggerWorkflow->>Infisical: fetches AGENT_MANAGER_PAT and workflow secrets
  Infisical-->>TriggerWorkflow: returns AGENT_MANAGER_PAT
  TriggerWorkflow->>GitHubAPI: sends dispatches request with Bearer AGENT_MANAGER_PAT
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • raaymax

Poem

A bunny hopped through YAML light,
With Infisical secrets tucked just right.
LaunchDarkly twinkled, PyPI too,
The agent dispatch went thump-thump through.
🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating GitHub Actions secrets from repository secrets to Infisical.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch seclift/infisical-github-actions-20260626-153312-r1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/publish.yml:
- Around line 39-47: Move the Infisical secret fetches in publish workflow
closer to where they are used so the tokens are not exposed for the whole job.
In the publish job, refactor the secret-loading step that uses infisical-secrets
to fetch LAUNCHDARKLY_ACCESS_TOKEN only before the build-related step that needs
it and PYPI_TOKEN only immediately before the publish/upload step, or scope them
via step outputs/env if supported. Keep the existing publish job flow intact
while limiting token lifetime around the relevant consumer steps.

In @.github/workflows/trigger-workflow.yml:
- Around line 69-75: The dispatch step currently can succeed even when
AGENT_MANAGER_PAT is missing or rejected, so the workflow may look successful
while the agent-manager trigger never happened. In the trigger-workflow.yml
dispatch block, add a guard before the curl call to verify AGENT_MANAGER_PAT is
present, and change the curl invocation to fail the job on non-2xx HTTP
responses by checking the returned status from the dispatch request. Keep the
fix localized to the dispatch logic that uses repo_owner, repo_name, event_type,
merged_payload, and AGENT_MANAGER_PAT.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c2a5225-ea56-40d4-8176-4667f1d62326

📥 Commits

Reviewing files that changed from the base of the PR and between 04ec778 and cb9c6f8.

📒 Files selected for processing (2)
  • .github/workflows/publish.yml
  • .github/workflows/trigger-workflow.yml

Comment on lines +39 to +47
- name: Fetch secrets from Infisical
uses: WriterInternal/devops-github-actions/infisical-secrets@cf0625c0cb6646c057b9bc81c49c8554b2313e27 # v2.3.0
with:
org-identity-id: ${{ secrets.INFISICAL_ORG_IDENTITY_UUID }}
org-project-slug: ${{ secrets.INFISICAL_ORG_PROJECT_SLUG }}
repo-identity-id: ${{ secrets.INFISICAL_REPO_IDENTITY_UUID }}
repo-project-slug: ${{ secrets.INFISICAL_REPO_PROJECT_SLUG }}
env-slug: prod
required-keys: LAUNCHDARKLY_ACCESS_TOKEN PYPI_TOKEN

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Fetch publish secrets closer to their consumers.

This step exports both LAUNCHDARKLY_ACCESS_TOKEN and PYPI_TOKEN before dependency install/build commands run, broadening token exposure beyond the upload/publish steps. Prefer fetching each token immediately before the step that needs it, or use step-scoped outputs/env if the composite action supports that.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/publish.yml around lines 39 - 47, Move the Infisical
secret fetches in publish workflow closer to where they are used so the tokens
are not exposed for the whole job. In the publish job, refactor the
secret-loading step that uses infisical-secrets to fetch
LAUNCHDARKLY_ACCESS_TOKEN only before the build-related step that needs it and
PYPI_TOKEN only immediately before the publish/upload step, or scope them via
step outputs/env if supported. Keep the existing publish job flow intact while
limiting token lifetime around the relevant consumer steps.

Comment on lines 69 to 75
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.AGENT_MANAGER_PAT }}" \
-H "Authorization: Bearer $AGENT_MANAGER_PAT" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
-d "{\"event_type\": \"$event_type\", \"client_payload\": $merged_payload}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Fail the job when the dispatch API rejects the migrated PAT.

If Infisical returns a missing/mis-scoped AGENT_MANAGER_PAT, GitHub can respond with 401/403 while curl still exits successfully. Add an explicit token guard and HTTP failure handling so the release does not appear successful when the agent-manager dispatch was skipped.

Suggested hardening
+        : "${AGENT_MANAGER_PAT:?AGENT_MANAGER_PAT was not populated by Infisical}"
+
-        curl -L \
+        curl --fail --show-error --silent -L \
           -X POST \
           -H "Accept: application/vnd.github+json" \
           -H "Authorization: Bearer $AGENT_MANAGER_PAT" \
#!/bin/bash
# Verify the dispatch curl invocation has explicit HTTP failure handling.
fd -i 'trigger-workflow.yml' .github/workflows --exec awk 'NR>=69 && NR<=75 {print NR ":" $0}' {}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/trigger-workflow.yml around lines 69 - 75, The dispatch
step currently can succeed even when AGENT_MANAGER_PAT is missing or rejected,
so the workflow may look successful while the agent-manager trigger never
happened. In the trigger-workflow.yml dispatch block, add a guard before the
curl call to verify AGENT_MANAGER_PAT is present, and change the curl invocation
to fail the job on non-2xx HTTP responses by checking the returned status from
the dispatch request. Keep the fix localized to the dispatch logic that uses
repo_owner, repo_name, event_type, merged_payload, and AGENT_MANAGER_PAT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant