Skip to content

Commit

Permalink
Update test github action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Hein Tonny Køien committed Sep 10, 2023
1 parent 1ce7eb6 commit 3940e43
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 25 deletions.
67 changes: 67 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Contributing to tf-plan-pr-comment

First off, thank you for considering contributing to tf-plan-pr-comment. It's people like you that make tf-plan-pr-comment such a great tool.

## Code of Conduct

This project and everyone participating in it is governed by the [tf-plan-pr-comment Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.

## How Can I Contribute?

### Reporting Bugs

- **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/blinqas/tf-plan-pr-comment/issues).

- If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/blinqas/tf-plan-pr-comment/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.

### Suggesting Enhancements

- Open a new issue with your suggestion.

### Your First Code Contribution

- Fork the repo.
- Create a new branch (`git checkout -b improve-feature`)
- Make the appropriate changes in the files.
- Add changes to reflect the changes made.
- Commit your changes (`git commit -am 'Improve feature'`)
- Push to the branch (`git push origin improve-feature`)
- Create a Pull Request.

### Pull Requests

1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations, and container parameters.
3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.

## Styleguides

### Git Commit Messages

- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or fewer

### Terraform Styleguide

- Use Terraform fmt for formatting.
- Use meaningful names for resources and variables.
- Comment your code where necessary.

## Additional Notes

### Issue and Pull Request Labels

This section lists the labels we use to help us track and manage issues and pull requests.

| Label name | Description |
| --- | --- |
| `bug` | Indicates a confirmed bug. |
| `enhancement` | Indicates a feature request. |
| `documentation` | Indicates a need for documentation. |

## License

By contributing, you agree that your contributions will be licensed under its MIT License.

55 changes: 30 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
# tf-plan-pr-comment

## Overview
tf-plan-pr-comment is a GitHub Action that automatically extracts and annotates essential Terraform plan output within GitHub Pull Requests. This action aims to enhance code reviews by providing a concise summary of the Terraform plan, making it easier for reviewers to understand the impact of the changes. It also aids in compliance by ensuring that only reviewed and approved Terraform changes are applied.

## Example Output

`tf-plan-pr-comment` is a GitHub Action designed to simplify code reviews and enhance compliance. It automatically extracts, annotates, and comments essential Terraform plan output within GitHub Pull Requests.

## Features
Extracts essential parts of the Terraform plan output.
Annotates the extracted output for better readability.
Comments the annotated output directly on the GitHub Pull Request.
Supports conditional comments based on the Terraform plan's exit code.
- **Automated Extraction**: Isolates crucial parts of the Terraform plan output.
- **Annotation**: Enhances readability by annotating the extracted output.
- **Pull Request Comments**: Posts the annotated output directly on the GitHub Pull Request.
- **Conditional Comments**: Supports comments based on the Terraform plan's exit code.

## Prerequisites
GitHub Actions must be enabled on your GitHub repository.
A Terraform project that you want to run this action on.
A GitHub Pull Request in the repository where you want to use this action.
- GitHub Actions enabled on your repository.
- A Terraform project to run this action on.
- An open GitHub Pull Request in the target repository.

## Inputs
Name Description Default Required
output_file The path to the file containing the Terraform plan output. None Yes

| Name | Description | Default | Required |
|---------------|-----------------------------------------------------|---------|----------|
| `output_file` | Path to the file with the Terraform plan output. | None | Yes |

## Usage
Add the following step to your GitHub Actions workflow YAML file:

yaml
```

```yaml
- name: Comment Terraform Plan on PR
uses: [Your_GitHub_Org]/tf-plan-pr-comment@v1
uses: blinqas/tf-plan-pr-comment@v1
with:
output_file: 'path/to/your/output/file'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
## Example Workflow
Here's an example workflow that demonstrates how to use tf-plan-pr-comment:
### Key Points:
- Use `-no-color` with terraform plan for parseable output.
- Utilize `2>&1` to redirect both `stdout` and `stderr` to the same file.
- Use `tee` to write the output to a file for the action.
- Assumes terraform plan runs from the repo root.

yaml
```
```yaml
name: Terraform CI
on:
Expand All @@ -56,15 +59,17 @@ jobs:
run: terraform plan -no-color 2>&1 | tee ${{ github.workspace }}/plan_output.txt
- name: Comment Terraform Plan on PR
uses: [Your_GitHub_Org]/tf-plan-pr-comment@v1
uses: blinqas/tf-plan-pr-comment@v1
with:
output_file: ${{ github.workspace }}/plan_output.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
## Example Comment on the Pull Request
![Example Comment in Pull Request](./images/example-output.png)

## Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
See CONTRIBUTING.md for contribution guidelines.

## License
This project is licensed under the MIT License - see the LICENSE.md file for details.

Feel free to modify this template to better suit your project's specific needs. This should give your users a good starting point for understanding how to use your GitHub Action effectively.
Licensed under MIT. See LICENSE.md for details.

0 comments on commit 3940e43

Please sign in to comment.