|
| 1 | +# Google GitHub Actions - Example Workflows |
| 2 | + |
| 3 | +## Example Workflows vs Starter Workflows |
| 4 | + |
| 5 | +### Starter Workflows |
| 6 | + |
| 7 | +Starter workflows should be considered _"as simple as is needed for the service"_. This is usually a common scenario with best practices so users can use it off-the-shelf with their applications. They are integrated with the GitHub user interface and are presented to users based on the types of files that exist in their repositories, see the categories property [here](https://github.com/actions/starter-workflows/blob/main/CONTRIBUTING.md). |
| 8 | + |
| 9 | +Additionally, starter workflows are reviewed by the GitHub team and have a published [contributing guide](https://github.com/actions/starter-workflows/blob/main/CONTRIBUTING.md). |
| 10 | + |
| 11 | +### Example Workflows |
| 12 | + |
| 13 | +Can be used to showcase any functionality for a given action. This may include examples for documentation or a blog article and may have highly specific use cases that don't make sense to surface as starter workflows. |
| 14 | + |
| 15 | +#### Example |
| 16 | + |
| 17 | +A good starter workflow for Cloud Run is to build a Docker container for your application, upload it Google Container Registry and then deploy the container Cloud Run. This is a common starting place and has everything needed to start using Cloud Run. |
| 18 | + |
| 19 | +A bad starter workflow for Cloud Run may have user specific logic or custom scripts and implementation steps. This could be good for a specific use case or documentation/blog article, but isn't simple or generic enough for all users to start with. |
| 20 | + |
| 21 | +## Adding Workflows |
| 22 | + |
| 23 | +New workflows should be bootstrapped with the provided go script: `go run scripts/generate.go workflow action-name/workflow-name`. This will generate the following items: |
| 24 | + |
| 25 | +- A new directory if it does not exist |
| 26 | + - `example-workflows/workflows/action-name` |
| 27 | +- A blank `README.md` file for the action folder if it does not exist |
| 28 | + - `example-workflows/workflows/action-name/workflow-name/README.md` |
| 29 | +- A blank workflow file |
| 30 | + - `example-workflows/workflows/action-name/workflow-name/workflow-name.yml` |
| 31 | +- A properties file for workflow metadata |
| 32 | + - `example-workflows/properties/workflow-name.properties.json` |
| 33 | +- An entry in the main `workflow.config.json` file |
| 34 | + |
| 35 | +### Prerequisites |
| 36 | + |
| 37 | +- Go verison 1.17+ |
| 38 | + |
| 39 | +### Usage |
| 40 | + |
| 41 | +#### Example Workflows |
| 42 | + |
| 43 | +```bash |
| 44 | +# Basic example workflow |
| 45 | +go run scripts/generate.go workflow auth/auth-simple |
| 46 | + |
| 47 | +# Folder Structure |
| 48 | +/example-workflows |
| 49 | + /workflows |
| 50 | + /auth |
| 51 | + auth-simple.yml |
| 52 | +``` |
| 53 | + |
| 54 | +#### Starter Workflows |
| 55 | + |
| 56 | +```bash |
| 57 | +# Starter workflow, default type (deployments) |
| 58 | +go run scripts/generate.go workflow --starter deploy-cloudrun/cloudrun-docker |
| 59 | + |
| 60 | +# Starter workflow, with type |
| 61 | +go run scripts/generate.go workflow --starter --type="automation" deploy-cloudrun/cloudrun-automation |
| 62 | + |
| 63 | +# Folder Structure |
| 64 | +/example-workflows |
| 65 | + /properties |
| 66 | + cloudrun-docker.properties.json |
| 67 | + cloudrun-automation.properties.json |
| 68 | + /workflows |
| 69 | + /deploy-cloudrun |
| 70 | + cloudrun-docker.yml |
| 71 | + cloudrun-automation.yml |
| 72 | +``` |
| 73 | + |
| 74 | +##### Valid Starter Types: |
| 75 | + |
| 76 | +- automation |
| 77 | +- ci |
| 78 | +- code-scanning |
| 79 | +- deployments (default) |
| 80 | + |
| 81 | +## Gnerate main `README.md` |
| 82 | + |
| 83 | +The main `README.md` file holds references to all the action folders and the workflows they contain. Run the following command to generate an updated `README.md` file based on the `templates/README.tmpl.md` file: |
| 84 | + |
| 85 | +```bash |
| 86 | +go run scripts/generate.go readme |
| 87 | +``` |
| 88 | + |
| 89 | +## Pull Request to GitHub Starter Workflows |
| 90 | + |
| 91 | +Updates to starter workflows should be merged into the GitHub Actions `actions/starter-workflows` repository. This can be done automatically by triggering the `Pull Request to GitHub` action or manually by following the steps below. |
| 92 | + |
| 93 | +**NOTE:** The GitHub Action is still a work in progress |
| 94 | + |
| 95 | +### Manual Process |
| 96 | + |
| 97 | +**NOTE:** This process assumes the `actions/starter-workflows` and `google-github-actions/example-workflows` repositories are siblings. |
| 98 | + |
| 99 | +```bash |
| 100 | +/some-directory |
| 101 | + /example-workflows |
| 102 | + [...] |
| 103 | + /starter-workflows |
| 104 | + [...] |
| 105 | +``` |
| 106 | + |
| 107 | +Steps: |
| 108 | + |
| 109 | +1. Fork the `actions/starter-workflows` respository from GitHub |
| 110 | +2. `cd` into `starter-workflows` |
| 111 | +3. Create a new branch: `git checkout -b <BRANCH_NAME>` |
| 112 | +4. `cd` into `example-workflows` |
| 113 | +5. Run the go script `go run scripts/release.go` to update the required files in the `actions/starter-workflows` repository |
| 114 | +6. Commit and push your changes to the `actions/starter-workflows` repository |
| 115 | +7. Create a Pull Request on the `actions/starter-workflows` respository |
0 commit comments