{"id":13769122,"url":"https://github.com/int128/argocd-commenter","last_synced_at":"2025-04-05T04:13:49.944Z","repository":{"id":37558936,"uuid":"320749625","full_name":"int128/argocd-commenter","owner":"int128","description":"Notify ArgoCD Application status via Pull Request comment or GitHub Deployment API","archived":false,"fork":false,"pushed_at":"2024-10-30T02:13:21.000Z","size":1752,"stargazers_count":133,"open_issues_count":14,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-30T04:58:34.892Z","etag":null,"topics":["argocd","golang","kubebuilder","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/int128.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-12T04:44:42.000Z","updated_at":"2024-10-30T02:12:10.000Z","dependencies_parsed_at":"2024-02-11T09:23:14.570Z","dependency_job_id":"78b68435-dc80-480b-810a-ab3a0cca24b7","html_url":"https://github.com/int128/argocd-commenter","commit_stats":{"total_commits":681,"total_committers":6,"mean_commits":113.5,"dds":0.3509544787077826,"last_synced_commit":"2d0fdbd2d0e337076367ba3075474855f7ea7e9d"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Fargocd-commenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Fargocd-commenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Fargocd-commenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Fargocd-commenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/int128","download_url":"https://codeload.github.com/int128/argocd-commenter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284951,"owners_count":20913704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argocd","golang","kubebuilder","kubernetes"],"created_at":"2024-08-03T17:00:17.760Z","updated_at":"2025-04-05T04:13:49.917Z","avatar_url":"https://github.com/int128.png","language":"Go","funding_links":[],"categories":["Ecosystem Projects"],"sub_categories":[],"readme":"# argocd-commenter [![docker](https://github.com/int128/argocd-commenter/actions/workflows/docker.yaml/badge.svg)](https://github.com/int128/argocd-commenter/actions/workflows/docker.yaml)\n\nThis is a Kubernetes Controller to notify a change of Argo CD Application status.\n\n## Example: Pull Request notification\n\nIn the [GitOps](https://www.weave.works/technologies/gitops/) way, you merge a pull request to deploy a change to Kubernetes cluster.\nargocd-commenter allows you to receive a notification comment after merging.\n\nWhen an Application is syncing, synced or healthy, argocd-commenter will create a comment.\n\n\u003cimg width=\"900\" alt=\"image\" src=\"https://github.com/int128/argocd-commenter/assets/321266/f94d45fe-905f-461c-9c4c-8d7a8f7978bf\"\u003e\n\nWhen the sync was failed, argocd-commenter will create a comment.\n\n\u003cimg width=\"900\" alt=\"image\" src=\"https://github.com/int128/argocd-commenter/assets/321266/a442bbe8-cb79-4c7e-95b7-cbe5eae7a44d\"\u003e\n\nSee the examples in [e2e-test fixtures](https://github.com/int128/argocd-commenter-e2e-test/pulls?q=is%3Apr+is%3Aclosed).\n\n### Sequence diagram\n\nHere is the sequence diagram of the deployment flow.\n\n```mermaid\nsequenceDiagram\n  actor User\n\n  User -\u003e\u003e+ GitHub Repository: git push\n  GitHub Repository --\u003e\u003e- User: pushed\n\n  loop Argo CD reconciler\n    Argo CD Application -\u003e\u003e+ GitHub Repository: git checkout\n    GitHub Repository --\u003e\u003e- Argo CD Application: manifest\n    note over Argo CD Application: Out of Sync\n    Argo CD Application -\u003e\u003e+ Kubernetes Deployment: kubectl apply\n    note over Argo CD Application: Syncing\n    Kubernetes Deployment --\u003e\u003e- Argo CD Application: applied\n    note over Argo CD Application: Synced\n  end\n\n  loop Kubernetes reconciler\n    Kubernetes Deployment -\u003e\u003e+ Kubernetes Pod: create\n    note over Argo CD Application: Progressing\n    Kubernetes Pod --\u003e\u003e- Kubernetes Deployment: ready\n    note over Argo CD Application: Healthy\n  end\n```\n\n## Example: GitHub Deployment notification\n\nIn a complex deployment flow, you can receive a notification using GitHub [Deployments](https://docs.github.com/en/rest/reference/deployments) API.\nFor example, when you deploy a preview environment for a pull request, you can receive the deployment statuses.\n\nTo receive a deployment status, set the following annotation to the Argo CD Application:\n\n```yaml\napiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n  annotations:\n    argocd-commenter.int128.github.io/deployment-url: https://api.github.com/repos/OWNER/REPO/deployments/ID\n```\n\nHere is an example of workflow to deploy a preview environment:\n\n```yaml\njobs:\n  deploy:\n    steps:\n      # Create a deployment\n      - uses: int128/deployment-action@v1\n        id: deployment\n\n      # Generate the manifests for a preview environment\n      - uses: actions/checkout@v2\n        with:\n          repository: your/manifests-repository\n          path: manifests-repository\n          token: # PAT or GitHub App token is required to write\n      - run: |\n          cp -a manifests \"manifests-repository/pr-${{ github.event.pull_request.number }}\"\n          cd \"manifests-repository/pr-${{ github.event.pull_request.number }}\"\n          sed -e 's|DEPLOYMENT_URL|${{ steps.deployment.outputs.url }}|g' applications/*.yaml\n\n      # Push the manifests for a preview environment\n      - run: |\n          git add .\n          git commit -m 'Deploy pr-${{ github.event.pull_request.number }}'\n          git push manifests-repository main\n```\n\nWhen the Application status is changed, argocd-commenter will create a deployment status.\n\n![image](https://user-images.githubusercontent.com/321266/139166278-e74f6d1b-c722-430f-850c-2f7135e251d6.png)\n\nSee the [e2e test](https://github.com/int128/argocd-commenter/blob/main/.github/workflows/docker.yaml) for details.\n\n### Sequence diagram\n\nHere is the sequence diagram of the deployment flow.\n\n```mermaid\nsequenceDiagram\n  actor User\n\n  User -\u003e\u003e+ Application Repository: git push\n  Application Repository --\u003e\u003e- User: pushed\n\n  Application Repository -\u003e\u003e+ GitHub Actions: start\n  GitHub Actions -\u003e\u003e+ GitHub Deployment: create\n  GitHub Deployment --\u003e\u003e- GitHub Actions: created\n  note over GitHub Deployment: Pending\n  GitHub Actions -\u003e\u003e+ Manifest Repository: git push\n  Manifest Repository --\u003e\u003e- GitHub Actions: pushed\n  GitHub Actions --\u003e\u003e- Application Repository: success\n\n  loop Argo CD reconciler\n    Argo CD Application -\u003e\u003e+ Manifest Repository: git checkout\n    Manifest Repository --\u003e\u003e- Argo CD Application: manifest\n    note over Argo CD Application: Out of Sync\n    note over GitHub Deployment: Queued\n    Argo CD Application -\u003e\u003e+ Kubernetes Deployment: kubectl apply\n    note over Argo CD Application: Syncing\n    Kubernetes Deployment --\u003e\u003e- Argo CD Application: applied\n    note over Argo CD Application: Synced\n    note over GitHub Deployment: In progress\n  end\n\n  loop Kubernetes reconciler\n    Kubernetes Deployment -\u003e\u003e+ Kubernetes Pod: create\n    note over Argo CD Application: Progressing\n    Kubernetes Pod --\u003e\u003e- Kubernetes Deployment: ready\n    note over Argo CD Application: Healthy\n    note over GitHub Deployment: Active\n  end\n```\n\n## Getting Started\n\n### Prerequisite\n\nArgo CD is running in your Kubernetes cluster.\n\n### Setup\n\nTo deploy the manifest:\n\n```shell\nkubectl apply -f https://github.com/int128/argocd-commenter/releases/download/v1.8.0/argocd-commenter.yaml\n```\n\nYou need to create either Personal Access Token or GitHub App.\n\n- Personal Access Token\n  - Belong to a user\n  - Share the rate limit in a user\n- GitHub App\n  - Belong to a user or organization\n  - Have each rate limit for an installation\n\n#### Option 1: Using a Personal Access Token\n\n1. Open https://github.com/settings/tokens\n1. Generate a new token\n1. Create a secret as follows:\n   ```shell\n   kubectl -n argocd-commenter-system create secret generic controller-manager \\\n     --from-literal=\"GITHUB_TOKEN=$YOUR_PERSONAL_ACCESS_TOKEN\"\n   ```\n\n#### Option 2: Using a GitHub App\n\n1. Create your GitHub App from either link:\n   - For a user: https://github.com/settings/apps/new?name=argocd-commenter\u0026url=https://github.com/int128/argocd-commenter\u0026webhook_active=false\u0026contents=read\u0026pull_requests=write\n   - For an organization: https://github.com/organizations/:org/settings/apps/new?name=argocd-commenter\u0026url=https://github.com/int128/argocd-commenter\u0026webhook_active=false\u0026contents=read\u0026pull_requests=write (replace `:org` with your organization)\n1. Get the **App ID** from the setting page\n1. [Download a private key of the GitHub App](https://docs.github.com/en/developers/apps/authenticating-with-github-apps)\n1. [Set a custom badge for the GitHub App](https://docs.github.com/en/developers/apps/creating-a-custom-badge-for-your-github-app)\n   - Logo of Argo CD is available in [CNCF Branding](https://cncf-branding.netlify.app/projects/argo/)\n1. [Install your GitHub App on your repository or organization](https://docs.github.com/en/developers/apps/installing-github-apps)\n1. Get the **Installation ID** from the URL, like `https://github.com/settings/installations/ID`\n1. Create a secret as follows:\n   ```shell\n   kubectl -n argocd-commenter-system create secret generic controller-manager \\\n     --from-literal=\"GITHUB_APP_ID=$YOUR_GITHUB_APP_ID\" \\\n     --from-literal=\"GITHUB_APP_INSTALLATION_ID=$YOUR_GITHUB_APP_INSTALLATION_ID\" \\\n     --from-file=\"GITHUB_APP_PRIVATE_KEY=/path/to/private-key.pem\"\n   ```\n\n### Verify setup\n\nMake sure the controller is running.\n\n```shell\nkubectl -n argocd-commenter-system rollout status deployment argocd-commenter-controller-manager\n```\n\n## Configuration\n\n### GitHub Enterprise Server\n\nSet the environment variable `GITHUB_ENTERPRISE_URL`.\n\n```shell\nkubectl -n argocd-commenter-system create secret generic controller-manager \\\n  --from-literal=\"GITHUB_TOKEN=$YOUR_PERSONAL_ACCESS_TOKEN\" \\\n  --from-literal=\"GITHUB_ENTERPRISE_URL=$YOUR_GITHUB_ENTERPRISE_URL\"\n```\n\n## Contribution\n\nThis is an open source software. Feel free to contribute to it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint128%2Fargocd-commenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fint128%2Fargocd-commenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint128%2Fargocd-commenter/lists"}