Skip to content

Commit bbe764a

Browse files
authored
feat: initial revision (#1)
* initial revision * fix: pr comments
1 parent 1341eb2 commit bbe764a

20 files changed

+1347
-1
lines changed

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: 'Pull Request to GitHub'
16+
17+
on: workflow_dispatch
18+
19+
env:
20+
PR_BRANCH: 'google-github-actions/update-${{github.sha}}'
21+
22+
jobs:
23+
pull-request:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: 'Checkout'
27+
uses: actions/checkout@v3
28+
with:
29+
path: ./example-workflows
30+
31+
- name: 'Setup go'
32+
uses: actions/setup-go@v3
33+
with:
34+
go-version: '^1.17.7'
35+
36+
- name: 'Checkout Starter Workflows'
37+
uses: actions/checkout@v3
38+
with:
39+
repository: actions/starter-workflows
40+
ref: main
41+
path: ./starter-workflows
42+
43+
- name: 'Create New Branch'
44+
working-directory: ./starter-workflows
45+
run: git checkout -b $PR_BRANCH
46+
47+
- name: 'Update Files'
48+
working-directory: ./example-workflows
49+
run: go run scripts/release.go
50+
51+
- name: 'Git Status'
52+
working-directory: ./starter-workflows
53+
run: git status
54+
55+
# - name: 'Push Branch to Remote'
56+
# working-directory: ./starter-workflows
57+
# run: git push origin main
58+
59+
# - name: 'Create Pull Request'
60+
# uses: actions/[email protected]
61+
# with:
62+
# script: |
63+
# const output = `
64+
# ## Update Google GitHub Actions Starter Workflows
65+
66+
# ### **NOTE: This is an automated pull request.**
67+
68+
# This pull request was created by the Google GitHub Actions team.
69+
70+
# Please refer to the https://github.com/google-github-actions/example-workflows for more information.
71+
# `;
72+
73+
# const response = await github.rest.pulls.create({
74+
# owner: `actions`,
75+
# repo: `starter-workflows`,
76+
# title: `Update Google GitHub Actions Starter Workflows`,
77+
# head: `${{env.PR_BRANCH}}`,
78+
# base: `main`,
79+
# maintainer_can_modify: true,
80+
# body: output
81+
# });
82+
#
83+
# console.log(`Pull Request #: ${response.number}`)
84+
# console.log(`HTML URL : ${response.html_url}`)
85+
#
86+
# console.log(`Response: `)
87+
# console.log(response)
88+

.github/workflows/validate-readme.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the 'License');
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an 'AS IS' BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: 'Validate Readme'
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
pull_request:
22+
branches:
23+
- main
24+
25+
jobs:
26+
gen-readme:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: 'Checkout'
30+
uses: actions/checkout@v3
31+
32+
- name: 'Setup go'
33+
uses: actions/setup-go@v3
34+
with:
35+
go-version: '^1.17.7'
36+
37+
- name: 'Generate Readme'
38+
run: go run scripts/generate.go readme
39+
40+
- name: 'Validate Diff'
41+
run: |
42+
STATUS=$(git status --porcelain)
43+
if [[ -n "$STATUS" ]]; then
44+
echo "ERROR: README has not been updated"
45+
echo ""
46+
echo " Run the following command to update the README: go run scripts/generate.go readme"
47+
exit 1
48+
fi

.gitignore

Whitespace-only changes.

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @google-github-actions/maintainers

CONTRIBUTING.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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

Comments
 (0)