Skip to content

Commit

Permalink
Update README Quickstart to use templating
Browse files Browse the repository at this point in the history
  • Loading branch information
alexchristy committed Oct 5, 2024
1 parent c23b6c8 commit 537eb18
Showing 1 changed file with 120 additions and 55 deletions.
175 changes: 120 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<summary>Table of Contents</summary>
<ol>
<li><a href="#key-features">Key Features</a></li>
<li><a href="#quickstart-public">Quickstart</a></li>
<li><a href="#private-setup">Private Setup</a></li>
<li><a href="#quickstart">Quickstart</a></li>
<li>
<a href="#pipeline-organization">Pipeline Organization</a>
<ul>
Expand All @@ -33,6 +32,13 @@
<li><a href="#troubleshooting">Troubleshooting</a></li>
<li><a href="#related">Related</a></li>
<li><a href="#license">License</a></li>
<li>
<a href="#deprecated-sections">Deprecated Sections</a>
<ul>
<li><a href="#deprecated-public-setup">Public Setup</a></li>
<li><a href="#deprecated-private-setup">Private Setup</a></li>
</ul>
</li>
</ol>
</details>

Expand All @@ -54,80 +60,43 @@
* Decoder Conflict Resolution
- Automatically disables default decoders that overlap with custom decoders.

## Quickstart (Public)
## Quickstart

1. Fork this repository and only copy the main branch

![Fork repo button](https://github.com/user-attachments/assets/f6e3dbbc-e7f3-4d79-9d38-3e82511d3bb0)

![Fork main branch only](https://github.com/user-attachments/assets/90a0ceae-fb0e-42b2-b22c-0d9c836cc724)
1. Click `Use this tempalte` in the top right corner.

2. Configure the three following Action secrets:
2. Click `Create a new repository`.

3. Configure the repository name, description, and visibility (Public or Private).

4. This will create a new repository in your GitHub account.
* *Note: The pipeline will **fail** with the intial commit. **This is expected***

5. Configure the three following Action secrets:

* `DOCKER_IMAGE` - The docker image used for testing. Publicly supported docker image: `alexchristy/wazuh-test-pipeline`
* `DOCKER_USERNAME` - Username for the docker account pulling the docker image. Ex: `[email protected]`
* `DOCKER_PASSWORD` - Password for the docker account pulling the docker image.

![Visual secret setup](https://github.com/user-attachments/assets/535f8523-6b15-42f8-9adb-57b830a772ec)

3. Enable GitHub Actions

![Enable GitHub Actions steps](https://github.com/user-attachments/assets/b89fba97-9aad-40cb-9560-437ad26aaa91)

4. Done!

You can now start creating pull requests or committing directly to main and see the tests run automatically. However, due to the nature of forked repositories, you repository will always be public. If this is an issue, follow the steps for a private repoistory setup.

## Private Setup

*This section is for the people people who need to run this pipeline in a private repository.*



1. [Create a new private repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-new-repository) in GitHub.

> **Note:** Ensure that the repository is **NOT** initialized with a README.md or any other files.
2. Create a fine-grained [GitHub token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) for the next step.

The token should only have access to the new private repository we just created.
6. **[Private Repos Only]** Create a fine-grained [GitHub token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) for the next step. The token should only have access to the new private repository we just created.

Required Repository permissions:
* Pull requests (Read-only)
* Metadata (Read-only)
* Contents (Read-only)

3. Configure the GitHub Action secrets, from step 2 in the [Quickstart](#quickstart-public) and an additional secret called `TOKEN` with the value of the token created in the previous step.
7. **[Private Repos Only]** Configure an additional secret called `TOKEN` with the value of the token created in the previous step.

4. Clone this repository.
8. Navigate to `Actions` and click the failed workflow run. (Usually there is only one called `Initial commit`)

```bash
git clone --bare https://github.com/alexchristy/wazuh-pipeline
```
9. In the top right, click `Re-run jobs`, then click `Re-run all jobs`

5. Enter directory.

```bash
cd wazuh-pipeline.git
```

5. Add a new remote
10. On the pop up click the green button `Re-run jobs`

```bash
git remote add private {NEW_REPO_URL}
```
11. The pipeline should completed successfully.

6. Push main branch to new repository

```bash
git push private main
```

>**Note:** If this step is failing ensure that the account you are using has proper access to the new repository.

7. Finished!

Pushing the main branch will kick off the CI pipeline which should run the default tests. If it passes then the repository is ready for use. If it fails then the repository is not functional and an issue should be filed with the GitHub Action log.

## Pipeline Organization

Expand Down Expand Up @@ -332,10 +301,106 @@ This happens because the pipeline does not have the `TOKEN` secret configured, s

*If this did not work, look at other sections in the [Troubleshooting](#troubleshooting) section for other solutions.*

### Write Access to Repository not Granted

This error causes the pipeline step named `Run container with branch and repo info` and usually occurs on the first or second run of the pipeline. The error in the pipeline/action log will say something like:

```txt
Cloning repository with token
Cloning into '/root/wazuh_pipeline'...
remote: Write access to repository not granted.
fatal: unable to access 'https://github.com/myusername/wazuh-pipeline/': The requested URL returned error: 403
/root/init.sh: line 17: cd: /root/wazuh_pipeline: No such file or directory
Could not cd in repo directory. The repo was likely not cloned properly!
If this is a private repo, make sure to include a GitHub token.
Error: Process completed with exit code 1.
```

This happens because the repository `TOKEN` secret is configured with a GitHub access token that does not have the correct permissions for the repository.

**Fix Steps:**

1. Starting at step 6, follow all the steps in the [Quickstart Section](#quickstart).

## Related

[wazuh-pipeline](https://github.com/alexchristy/wazuh-pipeline) - Wazuh CI pipeline that leverages this tool

## License

GNU General Public License v3.0

## Deprecated Sections

### [Deprecated] Public Setup

1. Fork this repository and only copy the main branch

![Fork repo button](https://github.com/user-attachments/assets/f6e3dbbc-e7f3-4d79-9d38-3e82511d3bb0)

![Fork main branch only](https://github.com/user-attachments/assets/90a0ceae-fb0e-42b2-b22c-0d9c836cc724)

2. Configure the three following Action secrets:

* `DOCKER_IMAGE` - The docker image used for testing. Publicly supported docker image: `alexchristy/wazuh-test-pipeline`
* `DOCKER_USERNAME` - Username for the docker account pulling the docker image. Ex: `[email protected]`
* `DOCKER_PASSWORD` - Password for the docker account pulling the docker image.

![Visual secret setup](https://github.com/user-attachments/assets/535f8523-6b15-42f8-9adb-57b830a772ec)

3. Enable GitHub Actions

![Enable GitHub Actions steps](https://github.com/user-attachments/assets/b89fba97-9aad-40cb-9560-437ad26aaa91)

4. Done!

You can now start creating pull requests or committing directly to main and see the tests run automatically. However, due to the nature of forked repositories, you repository will always be public. If this is an issue, follow the steps for a private repoistory setup.

### [Deprecated] Private Setup

*This section is for the people people who need to run this pipeline in a private repository.*

1. [Create a new private repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-new-repository) in GitHub.

> **Note:** Ensure that the repository is **NOT** initialized with a README.md or any other files.

2. Create a fine-grained [GitHub token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) for the next step.

The token should only have access to the new private repository we just created.

Required Repository permissions:
* Pull requests (Read-only)
* Metadata (Read-only)
* Contents (Read-only)

3. Configure the GitHub Action secrets, from step 2 in the [Quickstart](#quickstart-public) and an additional secret called `TOKEN` with the value of the token created in the previous step.

4. Clone this repository.

```bash
git clone --bare https://github.com/alexchristy/wazuh-pipeline
```

5. Enter directory.

```bash
cd wazuh-pipeline.git
```

5. Add a new remote

```bash
git remote add private {NEW_REPO_URL}
```

6. Push main branch to new repository

```bash
git push private main
```

>**Note:** If this step is failing ensure that the account you are using has proper access to the new repository.

7. Finished!

Pushing the main branch will kick off the CI pipeline which should run the default tests. If it passes then the repository is ready for use. If it fails then the repository is not functional and an issue should be filed with the GitHub Action log.

0 comments on commit 537eb18

Please sign in to comment.