Skip to content

fix(gitops): scope installation tokens to the destination repository - #11

Draft
patrickleet wants to merge 1 commit into
mainfrom
metaforge-staging-cutover
Draft

patrickleet wants to merge 1 commit into
mainfrom
metaforge-staging-cutover

Conversation

@patrickleet

Copy link
Copy Markdown
Contributor

GitHub App authentication requests a token for every repository in the caller organization's installation. The promotion and cleanup jobs use that token to write one configured environment repository. Adding a repository to the installation therefore exposes it to existing preview jobs.

Validate the configured owner/repo against the caller's organization and request a token for that repository alone. The selected repository, promotion and cleanup commands, and PAT authentication path retain their existing contracts.

Both token-scope steps passed same-organization, malformed, and cross-organization cases. The existing merge and value-composition contracts also passed.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Your preview environment has been published! 🚀

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Dry Run: Preview (Promotion PR)

Workflow validation completed successfully.

Settings

Setting Value
Environment Repository hops-ops/test-gitops
Project test-project
Application Name test-project-workflows-gitops-pr-11
Output File environment/.gitops/deploy/helm/templates/workflows-gitops-pr-11.yaml
Type Preview
Method Promotion PR

Completed

  • Helm template generated for test-project-workflows-gitops-pr-11
  • Changes detected: Yes

Skipped (dry run)

  • Commit to environment repository
  • Create PR in hops-ops/test-gitops
Environment Diff
diff --git a/.gitops/deploy/helm/templates/workflows-gitops-pr-11.yaml b/.gitops/deploy/helm/templates/workflows-gitops-pr-11.yaml
new file mode 100644
index 0000000..0e0af30
--- /dev/null
+++ b/.gitops/deploy/helm/templates/workflows-gitops-pr-11.yaml
@@ -0,0 +1,58 @@
+---
+# Source: promotion/templates/application.yaml
+apiVersion: argoproj.io/v1alpha1
+kind: Application
+metadata:
+  name: test-project-workflows-gitops-pr-11
+  namespace: argocd
+  finalizers:
+    - resources-finalizer.argocd.argoproj.io
+spec:
+  project: test-project
+  source:
+    path: .gitops/deploy/helm
+    repoURL: https://github.com/hops-ops/workflows-gitops.git
+    targetRevision: metaforge-staging-cutover
+    helm:
+      version: v3
+      values: |
+        env:
+          test: true
+          type: preview
+          method: promotion-pr
+          event: pr
+        image:
+          tag: pr-11-77a512d0ffd89a8e1b13a9a4b75a2ce3312d2176
+  destination:
+    namespace: workflows-gitops-pr-11
+    server: https://kubernetes.default.svc
+  syncPolicy:
+    automated:
+      selfHeal: true
+      prune: true
+---
+# Source: promotion/templates/preview-resources.yaml
+apiVersion: argoproj.io/v1alpha1
+kind: Application
+metadata:
+  name: something
+  namespace: argocd
+  annotations:
+    argocd.argoproj.io/sync-wave: "-1"
+  finalizers:
+    - resources-finalizer.argocd.argoproj.io
+spec:
+  project: test-project
+  source:
+    path: .gitops/deploy/helm
+    repoURL: https://github.com/unbounded-tech/something.git
+    targetRevision: main
+    helm:
+      version: v3
+  destination:
+    namespace: workflows-gitops-pr-11
+    server: https://kubernetes.default.svc
+  syncPolicy:
+    automated:
+      selfHeal: true
+      prune: true
Generated Output File
---
# Source: promotion/templates/application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: test-project-workflows-gitops-pr-11
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: test-project
  source:
    path: .gitops/deploy/helm
    repoURL: https://github.com/hops-ops/workflows-gitops.git
    targetRevision: metaforge-staging-cutover
    helm:
      version: v3
      values: |
        env:
          test: true
          type: preview
          method: promotion-pr
          event: pr
        image:
          tag: pr-11-77a512d0ffd89a8e1b13a9a4b75a2ce3312d2176
  destination:
    namespace: workflows-gitops-pr-11
    server: https://kubernetes.default.svc
  syncPolicy:
    automated:
      selfHeal: true
      prune: true
---
# Source: promotion/templates/preview-resources.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: something
  namespace: argocd
  annotations:
    argocd.argoproj.io/sync-wave: "-1"
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: test-project
  source:
    path: .gitops/deploy/helm
    repoURL: https://github.com/unbounded-tech/something.git
    targetRevision: main
    helm:
      version: v3
  destination:
    namespace: workflows-gitops-pr-11
    server: https://kubernetes.default.svc
  syncPolicy:
    automated:
      selfHeal: true
      prune: true

This was a dry run. No changes were made to the environment repository.

hops-gitops Bot pushed a commit to hops-ops/test-gitops that referenced this pull request Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Dry Run: Release (Promotion)

Workflow validation completed successfully.

Settings

Setting Value
Environment Repository hops-ops/test-gitops
Project test-project
Application Name test-project-workflows-gitops
Output File environment/.gitops/deploy/helm/templates/workflows-gitops.yaml
Type Release
Method Promotion

Completed

  • Helm template generated for test-project-workflows-gitops
  • Changes detected: Yes

Skipped (dry run)

  • Commit to environment repository
  • Push to hops-ops/test-gitops
Environment Diff
diff --git a/.gitops/deploy/helm/templates/workflows-gitops.yaml b/.gitops/deploy/helm/templates/workflows-gitops.yaml
index baa560a..6f9fa27 100644
--- a/.gitops/deploy/helm/templates/workflows-gitops.yaml
+++ b/.gitops/deploy/helm/templates/workflows-gitops.yaml
@@ -12,7 +12,7 @@ spec:
   source:
     path: .gitops/deploy/helm
     repoURL: https://github.com/hops-ops/workflows-gitops.git
-    targetRevision: v2.1.3
+    targetRevision: refs/pull/11/merge
     helm:
       version: v3
       values: |
@@ -20,7 +20,7 @@ spec:
           test: true
           type: release
           method: promotion
-          event: v-tag
+          event: pr
   destination:
     namespace: test-project
     server: https://kubernetes.default.svc
Generated Output File
---
# Source: promotion/templates/application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: test-project-workflows-gitops
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: test-project
  source:
    path: .gitops/deploy/helm
    repoURL: https://github.com/hops-ops/workflows-gitops.git
    targetRevision: refs/pull/11/merge
    helm:
      version: v3
      values: |
        env:
          test: true
          type: release
          method: promotion
          event: pr
  destination:
    namespace: test-project
    server: https://kubernetes.default.svc
  syncPolicy:
    automated:
      selfHeal: true
      prune: true

This was a dry run. No changes were made to the environment repository.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Dry Run: Preview (Promotion PR)

Workflow validation completed successfully.

Settings

Setting Value
Environment Repository hops-ops/test-gitops
Project test-project
Application Name test-project-workflows-gitops-pr-11
Output File environment/.gitops/deploy/helm/templates/workflows-gitops-pr-11.yaml
Type Preview
Method Promotion PR

Completed

  • Helm template generated for test-project-workflows-gitops-pr-11
  • Changes detected: Yes

Skipped (dry run)

  • Commit to environment repository
  • Create PR in hops-ops/test-gitops
Environment Diff
diff --git a/.gitops/deploy/helm/templates/workflows-gitops-pr-11.yaml b/.gitops/deploy/helm/templates/workflows-gitops-pr-11.yaml
new file mode 100644
index 0000000..013fe69
--- /dev/null
+++ b/.gitops/deploy/helm/templates/workflows-gitops-pr-11.yaml
@@ -0,0 +1,58 @@
+---
+# Source: promotion/templates/application.yaml
+apiVersion: argoproj.io/v1alpha1
+kind: Application
+metadata:
+  name: test-project-workflows-gitops-pr-11
+  namespace: argocd
+  finalizers:
+    - resources-finalizer.argocd.argoproj.io
+spec:
+  project: test-project
+  source:
+    path: .gitops/deploy/helm
+    repoURL: https://github.com/hops-ops/workflows-gitops.git
+    targetRevision: metaforge-staging-cutover
+    helm:
+      version: v3
+      values: |
+        env:
+          test: true
+          type: preview
+          method: promotion-pr-merge
+          event: pr
+        image:
+          tag: pr-11-77a512d0ffd89a8e1b13a9a4b75a2ce3312d2176
+  destination:
+    namespace: workflows-gitops-pr-11
+    server: https://kubernetes.default.svc
+  syncPolicy:
+    automated:
+      selfHeal: true
+      prune: true
+---
+# Source: promotion/templates/preview-resources.yaml
+apiVersion: argoproj.io/v1alpha1
+kind: Application
+metadata:
+  name: something
+  namespace: argocd
+  annotations:
+    argocd.argoproj.io/sync-wave: "-1"
+  finalizers:
+    - resources-finalizer.argocd.argoproj.io
+spec:
+  project: test-project
+  source:
+    path: .gitops/deploy/helm
+    repoURL: https://github.com/unbounded-tech/something.git
+    targetRevision: main
+    helm:
+      version: v3
+  destination:
+    namespace: workflows-gitops-pr-11
+    server: https://kubernetes.default.svc
+  syncPolicy:
+    automated:
+      selfHeal: true
+      prune: true
Generated Output File
---
# Source: promotion/templates/application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: test-project-workflows-gitops-pr-11
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: test-project
  source:
    path: .gitops/deploy/helm
    repoURL: https://github.com/hops-ops/workflows-gitops.git
    targetRevision: metaforge-staging-cutover
    helm:
      version: v3
      values: |
        env:
          test: true
          type: preview
          method: promotion-pr-merge
          event: pr
        image:
          tag: pr-11-77a512d0ffd89a8e1b13a9a4b75a2ce3312d2176
  destination:
    namespace: workflows-gitops-pr-11
    server: https://kubernetes.default.svc
  syncPolicy:
    automated:
      selfHeal: true
      prune: true
---
# Source: promotion/templates/preview-resources.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: something
  namespace: argocd
  annotations:
    argocd.argoproj.io/sync-wave: "-1"
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: test-project
  source:
    path: .gitops/deploy/helm
    repoURL: https://github.com/unbounded-tech/something.git
    targetRevision: main
    helm:
      version: v3
  destination:
    namespace: workflows-gitops-pr-11
    server: https://kubernetes.default.svc
  syncPolicy:
    automated:
      selfHeal: true
      prune: true

This was a dry run. No changes were made to the environment repository.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Dry Run: Release (Promotion PR)

Workflow validation completed successfully.

Settings

Setting Value
Environment Repository hops-ops/test-gitops
Project test-project
Application Name test-project-workflows-gitops
Output File environment/.gitops/deploy/helm/templates/workflows-gitops.yaml
Type Release
Method Promotion PR

Completed

  • Helm template generated for test-project-workflows-gitops
  • Changes detected: Yes

Skipped (dry run)

  • Commit to environment repository
  • Create PR in hops-ops/test-gitops
Environment Diff
diff --git a/.gitops/deploy/helm/templates/workflows-gitops.yaml b/.gitops/deploy/helm/templates/workflows-gitops.yaml
index baa560a..075a1d9 100644
--- a/.gitops/deploy/helm/templates/workflows-gitops.yaml
+++ b/.gitops/deploy/helm/templates/workflows-gitops.yaml
@@ -12,15 +12,15 @@ spec:
   source:
     path: .gitops/deploy/helm
     repoURL: https://github.com/hops-ops/workflows-gitops.git
-    targetRevision: v2.1.3
+    targetRevision: refs/pull/11/merge
     helm:
       version: v3
       values: |
         env:
           test: true
           type: release
-          method: promotion
-          event: v-tag
+          method: promotion-pr-merge
+          event: pr
   destination:
     namespace: test-project
     server: https://kubernetes.default.svc
Generated Output File
---
# Source: promotion/templates/application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: test-project-workflows-gitops
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: test-project
  source:
    path: .gitops/deploy/helm
    repoURL: https://github.com/hops-ops/workflows-gitops.git
    targetRevision: refs/pull/11/merge
    helm:
      version: v3
      values: |
        env:
          test: true
          type: release
          method: promotion-pr-merge
          event: pr
  destination:
    namespace: test-project
    server: https://kubernetes.default.svc
  syncPolicy:
    automated:
      selfHeal: true
      prune: true

This was a dry run. No changes were made to the environment repository.

@patrickleet

Copy link
Copy Markdown
Contributor Author

@gitkb-rabbit review

@patrickleet patrickleet added the meta-preview Include in the shared branch preview label Dec 3, 2026

This branch was successfully deployed

9 active and 1 inactive deployments
on-pr-preview-promotion-pr — 77a512d0 Deployed Dec 3, 2026 by patrickleet via Dry Run - Preview Promotion PR / argocd-promote-helm #15
on-pr-release-promotion-pr — 77a512d0 Deployed Dec 3, 2026 by patrickleet via Dry Run - Release Promotion PR / argocd-promote-helm #15
on-pr-release-promotion-pr-merge — 77a512d0 Deployed Dec 3, 2026 by patrickleet via Dry Run - Release Promotion PR + Merge / argocd-promote-helm #15
on-pr-preview-promotion-pr-merge — 77a512d0 Deployed Dec 3, 2026 by patrickleet via Dry Run - Preview Promotion PR + Merge / argocd-promote-helm #15
on-pr-preview-promotion — 77a512d0 Deployed Dec 3, 2026 by patrickleet via Dry Run - Preview Promotion / argocd-promote-helm #15
on-push-preview-promotion-pr — 77a512d0 Deployed Dec 3, 2026 by patrickleet via Dry Run - Preview Promotion PR / argocd-promote-helm #15
on-push-preview-promotion — 77a512d0 Deployed Dec 3, 2026 by patrickleet via Preview Promotion / argocd-promote-helm #15
on-push-release-promotion-pr — 77a512d0 Deployed Dec 3, 2026 by patrickleet via Dry Run - Release Promotion PR / argocd-promote-helm #15
on-push-release-promotion — 77a512d0 Deployed Dec 3, 2026 by patrickleet via Dry Run - Release Promotion / argocd-promote-helm #15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta-preview Include in the shared branch preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant