|
| 1 | +--- |
| 2 | +sidebar_position: 100 |
| 3 | +--- |
| 4 | + |
| 5 | +# Getting Started |
| 6 | + |
| 7 | +In the Getting Started, you can set up gha-trigger and experience CI with gha-trigger. |
| 8 | + |
| 9 | +## Requirement |
| 10 | + |
| 11 | +- Git |
| 12 | +- Terraform |
| 13 | +- GitHub Account |
| 14 | +- AWS Account |
| 15 | + |
| 16 | +## Steps |
| 17 | + |
| 18 | +1. Create GitHub Repositories from template repositories |
| 19 | +1. Create Webhook Secret |
| 20 | +1. Create GitHub App(s) |
| 21 | +1. Set up Terraform Configuration |
| 22 | +1. Apply Terraform |
| 23 | +1. Try to run CI |
| 24 | +1. Clean up |
| 25 | + |
| 26 | +### Create GitHub Repositories from template repositories |
| 27 | + |
| 28 | +- Main Repository: |
| 29 | +- CI Repository: |
| 30 | + |
| 31 | +### Create Webhook Secret |
| 32 | + |
| 33 | +- https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks |
| 34 | + |
| 35 | +### Create GitHub App(s) |
| 36 | + |
| 37 | +- https://docs.github.com/en/developers/apps/building-github-apps/creating-a-github-app |
| 38 | + |
| 39 | +You have to create GitHub App for two purposes. |
| 40 | + |
| 41 | +1. Receive webhook and trigger GitHub Actions Workflow |
| 42 | +2. Access Main Repository in CI of CI Repository |
| 43 | + |
| 44 | +You can use one GitHub App for the above purposes or can create two GitHub Apps for each purpose. |
| 45 | + |
| 46 | +You have to install GitHub App in Main Repository and CI Repository. |
| 47 | +You can either use the same GitHub App or create GitHub Apps per repository. |
| 48 | + |
| 49 | +In this Getting Started, let's use the same GitHub App for simplicity. |
| 50 | + |
| 51 | +#### 1. Receive webhook and trigger GitHub Actions Workflow |
| 52 | + |
| 53 | +The minimum setting of GitHub App (1). |
| 54 | + |
| 55 | +- Webhook: Active |
| 56 | +- Permissions |
| 57 | + - Actions: Read and write |
| 58 | + - Issues: Read-only |
| 59 | + - Pull requests: Read and write |
| 60 | +- Install this App in both Main Repository and CI Repository |
| 61 | + |
| 62 | +#### 2. Receive webhook and trigger GitHub Actions Workflow |
| 63 | + |
| 64 | +The minimum setting of GitHub App (2). |
| 65 | + |
| 66 | +- Webhook: Inactive |
| 67 | +- Permissions |
| 68 | + - Commit statuses: Read and write |
| 69 | + - Contents: Read |
| 70 | +- Install this App in both Main Repository and CI Repository |
| 71 | +- Register GitHub App ID and Private Key as CI Repository's GitHub Secrets |
| 72 | + |
| 73 | +### Set up Terraform Configuration |
| 74 | + |
| 75 | +```console |
| 76 | +$ git clone https://github.com/suzuki-shunsuke/gha-trigger |
| 77 | +$ cd gha-trigger/terraform |
| 78 | +``` |
| 79 | + |
| 80 | +[Download a zip file from Release page](https://github.com/suzuki-shunsuke/gha-trigger/releases) on this directory. |
| 81 | + |
| 82 | +Create `config.yaml`, `secret.yaml`, and `terraform.tfvars` from templates. |
| 83 | + |
| 84 | +```console |
| 85 | +$ cp config.yaml.tmpl config.yaml |
| 86 | +$ vi config.yaml |
| 87 | + |
| 88 | +$ cp secret.yaml.tmpl secret.yaml |
| 89 | +$ vi secret.yaml |
| 90 | + |
| 91 | +$ cp terraform.tfvars.tmpl terraform.tfvars |
| 92 | +$ vi terraform.tfvars |
| 93 | +``` |
| 94 | + |
| 95 | +### Apply Terraform |
| 96 | + |
| 97 | +Create resources. |
| 98 | + |
| 99 | +```console |
| 100 | +$ terraform apply [-refresh=false] |
| 101 | +``` |
| 102 | + |
| 103 | +`-refresh=false` is useful to make terraform commands fast. |
| 104 | + |
| 105 | +### Try |
| 106 | + |
| 107 | +Create a pull request to source repository to test CI. |
| 108 | + |
| 109 | +## Clean up |
| 110 | + |
| 111 | +``` |
| 112 | +$ terraform destroy |
| 113 | +``` |
0 commit comments