{"id":29917906,"url":"https://github.com/tchupp/actions-terraform-pr","last_synced_at":"2025-08-02T05:19:02.326Z","repository":{"id":41868259,"uuid":"360550555","full_name":"tchupp/actions-terraform-pr","owner":"tchupp","description":"GitHub Action for adding `terraform plan` output as a PR comment","archived":false,"fork":false,"pushed_at":"2025-07-10T14:42:54.000Z","size":42,"stargazers_count":7,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-10T21:15:50.965Z","etag":null,"topics":["github-actions","terraform"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tchupp.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,"zenodo":null}},"created_at":"2021-04-22T14:35:35.000Z","updated_at":"2025-07-10T14:42:42.000Z","dependencies_parsed_at":"2024-02-09T15:43:13.352Z","dependency_job_id":"f8141478-9eb3-40af-9ce2-17597006416f","html_url":"https://github.com/tchupp/actions-terraform-pr","commit_stats":{"total_commits":50,"total_committers":3,"mean_commits":"16.666666666666668","dds":0.26,"last_synced_commit":"f1a33c9702b70592a2477a31904c8d854012a155"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/tchupp/actions-terraform-pr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchupp%2Factions-terraform-pr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchupp%2Factions-terraform-pr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchupp%2Factions-terraform-pr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchupp%2Factions-terraform-pr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tchupp","download_url":"https://codeload.github.com/tchupp/actions-terraform-pr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchupp%2Factions-terraform-pr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268338706,"owners_count":24234541,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["github-actions","terraform"],"created_at":"2025-08-02T05:19:01.645Z","updated_at":"2025-08-02T05:19:02.298Z","avatar_url":"https://github.com/tchupp.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Actions: Terraform PR\n\nGitHub Action for adding `terraform plan` output as a PR comment.\n\n**[Shut up and show me the copy/paste](#examples)**\n\n## Usage\n\nThis action can be used as follows:\n```yaml\n      - uses: tchupp/actions-terraform-pr@v1\n        with:\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n          apply-branch: \"main\"\n```\n\n### Assumptions\n\nThe most common cause for issues involves a mismatch in expectations.  \nPlease read below to make sure your setup aligns with the assumptions made by this action.\n\n#### Setup\n\nThis action expects that the repo has been checked out and terraform has been set up with the correct version.  \nThe following snippet from an example job, [which can be found below](#simple-setup).\n\n```yaml\n...\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Setup Terraform\n        uses: hashicorp/setup-terraform@v2\n        with:\n          terraform_version: ~1.0.0\n          cli_config_credentials_token: ${{ secrets.TF_TOKEN }}\n...\n```\n\n#### Terraform Workspaces\n\nSome teams choose to have multiple sets of terraform configuration in one git repository.  \nLet's say your repo looked like this:\n```bash\n$ tree\n.\n├── aws-route53\n│   ├── main.tf\n│   └── versions.tf\n└── aws-vpc\n    ├── main.tf\n    └── versions.tf\n\n2 directories, 4 files\n```\n\nIf you had `development`, `staging`, and `production` workspaces for both sets of config files, you would have 6 workspaces total.\n\nThis action expects that your terraform workspace is uniquely named, at least inside your repository.\nThat means the workspace names would be:\n- `aws-route53-development`\n- `aws-route53-staging`\n- `aws-route53-production`\n- `aws-vpc-development`\n- `aws-vpc-staging`\n- `aws-vpc-production`\n\nThis naming scheme is common when using a backend such as Terraform Cloud.\n\n### Inputs\n\n#### github-token\n\n**Optional**. Uses to comment on PRs.  \nThis will default to `${{ secrets.GITHUB_TOKEN }}` if omitted.\n\n#### apply-branch\n\n**Optional**. Set this to the default branch for your repo, ex `main` or `master`.  \nLeave blank to disable auto-apply.\n\n#### path\n\n**Optional**. Set this to the path to your terraform configuration files.  \nThis will default to the top level directory if not specified.\n\n#### pr-comment-title\n\n**Optional**. Set this to specify a custom PR title.  \nThis will default to '${TF_WORKSPACE}' if not specified.\n\n## Examples\n\n### Simple Setup\n\nThis setup assumes you have your terraform files at the top level of your repo, and you only have a single workspace:\n```bash\n$ tree\n.\n├── main.tf\n└── versions.tf\n\n0 directories, 2 files\n```\n\nIn your `.github/workflows/terraform.yml` file you would have:\n```yaml\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n    paths:\n      - '**.tf'\n      - '.github/workflows/terraform.yml'\n\njobs:\n  terraform:\n    name: \"Terraform\"\n    runs-on: ubuntu-latest\n    env:\n      TF_WORKSPACE: \"default\"\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Setup Terraform\n        uses: hashicorp/setup-terraform@v2\n        with:\n          terraform_version: ~1.0.0\n          cli_config_credentials_token: ${{ secrets.TF_TOKEN }}\n\n      - uses: tchupp/actions-terraform-pr@v1\n        with:\n          apply-branch: \"main\"\n```\n\n### Single directory with a single workspace\n\nThis setup assumes you have your terraform files in a subdirectory in your repo, and you only have a single workspace:\n```bash\n$ tree\n.\n├── app\n│   ├── index.ts\n└── terraform\n    ├── main.tf\n    └── versions.tf\n\n2 directories, 3 files\n```\n\nIn your `.github/workflows/terraform.yml` file you would have:\n```yaml\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n    paths:\n      - '**.tf'\n      - '.github/workflows/terraform.yml'\n\njobs:\n  terraform:\n    name: \"Terraform\"\n    runs-on: ubuntu-latest\n    env:\n      TF_WORKSPACE: \"default\"\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Setup Terraform\n        uses: hashicorp/setup-terraform@v2\n        with:\n          terraform_version: ~1.0.0\n          cli_config_credentials_token: ${{ secrets.TF_TOKEN }}\n\n      - uses: tchupp/actions-terraform-pr@v1\n        with:\n          apply-branch: \"main\"\n          path: \"terraform\"\n```\n\n### Single directory with multiple workspaces\n\nThis setup assumes you have your terraform files in a subdirectory in your repo, and you only have a single workspace:\n```bash\n$ tree\n.\n├── app\n│   ├── index.ts\n└── terraform\n    ├── main.tf\n    └── versions.tf\n\n2 directories, 3 files\n```\n\nIn your `.github/workflows/terraform.yml` file you would have:\n```yaml\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n    paths:\n      - '**.tf'\n      - '.github/workflows/terraform.yml'\n\njobs:\n  terraform:\n    name: \"Terraform\"\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        env:\n          - development\n          - staging\n          - production\n    env:\n      TF_WORKSPACE: \"${{ matrix.env }}\"\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Setup Terraform\n        uses: hashicorp/setup-terraform@v2\n        with:\n          terraform_version: ~1.0.0\n          cli_config_credentials_token: ${{ secrets.TF_TOKEN }}\n\n      - uses: tchupp/actions-terraform-pr@v1\n        with:\n          apply-branch: \"main\"\n          path: \"terraform\"\n```\n\n### Manual Terraform Apply\n\nIn some situations, you want to control the `terraform apply` yourself.\n\nIn your `.github/workflows/terraform.yml` file you would have:\n```yaml\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n    paths:\n      - '**.tf'\n      - '.github/workflows/terraform.yml'\n\njobs:\n  terraform:\n    name: \"Terraform\"\n    runs-on: ubuntu-latest\n    env:\n      TF_WORKSPACE: \"default\"\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Setup Terraform\n        uses: hashicorp/setup-terraform@v2\n        with:\n          terraform_version: ~1.0.0\n          cli_config_credentials_token: ${{ secrets.TF_TOKEN }}\n\n      - uses: tchupp/actions-terraform-pr@v1\n\n      - name: Terraform Apply\n        if: github.ref == 'refs/heads/main'\n        run: |\n          terraform apply -auto-approve\n```\n\n### Disable locking for `terraform plan`\n\nIn some situations, you want to disabling workspace locking when running `terraform plan`.  \nThis would be the equivalent of running `terraform plan -lock=false`: https://www.terraform.io/language/state/locking\n\nIn your `.github/workflows/terraform.yml` file you would have:\n```yaml\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n    paths:\n      - '**.tf'\n      - '.github/workflows/terraform.yml'\n\njobs:\n  terraform:\n    name: \"Terraform\"\n    runs-on: ubuntu-latest\n    env:\n      TF_WORKSPACE: \"default\"\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Setup Terraform\n        uses: hashicorp/setup-terraform@v2\n        with:\n          terraform_version: ~1.0.0\n          cli_config_credentials_token: ${{ secrets.TF_TOKEN }}\n\n      - uses: tchupp/actions-terraform-pr@v1\n        with:\n          apply-branch: \"main\"\n          lock-for-plan: false\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftchupp%2Factions-terraform-pr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftchupp%2Factions-terraform-pr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftchupp%2Factions-terraform-pr/lists"}