GitHub Action: auto-format
Github Action Auto-Format runs several repository "hygiene" tasks for repositories:
- The
readme
target will rebuildREADME.md
fromREADME.yaml
. - The
github_format
target adds all of Cloud Posse's standard repository housekeeping files (including GitHub Actions workflows) to the repository's.github
folder. - The
terraform_format
target ensures consistent formatting across all Terraform files in the repository.
Usage
If you haven't already, follow the steps in the quickstart section.
To choose which pieces of functionality will be executed, modify the script-names:
input to the cloudposse/github-action-auto-format
step to be a comma-separated list of one or more targets (e.g., script-names: readme,terraform_format,github_format
).
This is an exhaustive list of all valid script-name
s:
readme
github_format
terraform_format
If you're using theauto-format.yml
workflow file distributed within this repository, then the Auto-format GitHub Action will trigger on pull request events, once a day at 7am UTC, and upon manual triggering via theworkflow_dispatch
mechanism.
Quick Start
Here's how to get started...
- Copy
.github/workflows/auto-format.yml
to the corresponding folder in your target repo. - Generate a Personal Access Token (PAT) that with the
workflow
permission using a GitHub account that haswrite
permissions in the target repo by following the directions here and selecting theworkflow
tick box on the token creation screen. - Add this token as a GitHub secret in your target repository and set the
workflow-token
input of thegithub-action-auto-format
step to the name of your secret. - Set the
bot-name
input of thegithub-action-auto-format
step to the GitHub username of the user who generated the token in step 2. *This user must havewrite
permissions in the target repo.` - By default, the Auto-Format GitHub Action will execute all of its scripts when run. If you'd like to use a subset of the full functionality, modify the
script-names
input of thegithub-action-auto-format
step as described in the usage section. - (Optional) You may want to change when the scheduled cron trigger is executed. If you'd like a guide, here's a useful resource for help in crafting cron strings - https://crontab.guru/
- (Optional) CloudPosse recommends pinning to specific versions of actions for ease of long-term maintenance. If you care to edit the pin in
auto-format.yml
frommain
to a specific version, feel free to consult https://github.com/cloudposse/github-action-auto-format/releases for a list of available versions.
Examples
Here's a real world example:
github-action-auto-format
- Cloud Posse's self-testing Auto-Format GitHub Action