Skip to content

Commit ebc3380

Browse files
authored
Merge pull request #7 from zeroae/chore/github
Chore/GitHub
2 parents 4dba2c8 + c7f5929 commit ebc3380

File tree

13 files changed

+365
-76
lines changed

13 files changed

+365
-76
lines changed

.github/.DS_Store

6 KB
Binary file not shown.

.github/CODEOWNERS

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
# Use this file to define individuals or teams that are responsible for code in a repository.
22
# Read more: <https://help.github.com/articles/about-codeowners/>
33
#
4-
# Order is important: the last matching pattern takes the most precedence
4+
# Order is important: the last matching pattern has the highest precedence
55

66
# These owners will be the default owners for everything
7-
* @cloudposse/engineering @cloudposse/contributors
7+
* @zeroae/engineering
88

99
# Cloud Posse must review any changes to Makefiles
10-
**/Makefile @cloudposse/engineering
11-
**/Makefile.* @cloudposse/engineering
10+
**/Makefile @zeroae/engineering
11+
**/Makefile.* @zeroae/engineering
1212

1313
# Cloud Posse must review any changes to GitHub actions
14-
.github/* @cloudposse/engineering
14+
.github/* @zeroae/engineering
1515

16-
# Cloud Posse must review any changes to standard context definition
17-
**/context.tf @cloudposse/engineering
16+
# Cloud Posse must review any changes to standard context definition,
17+
# but some changes can be rubber-stamped.
18+
**/*.tf @zeroae/engineering @zeroae/approvers
19+
README.yaml @zeroae/engineering @zeroae/approvers
20+
README.md @zeroae/engineering @zeroae/approvers
21+
docs/*.md @zeroae/engineering @zeroae/approvers
22+
23+
# Cloud Posse Admins must review all changes to CODEOWNERS or the mergify configuration
24+
.github/mergify.yml @zeroae/admins
25+
.github/CODEOWNERS @zeroae/admins

.github/auto-release.yml

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,36 @@ version-template: '$MAJOR.$MINOR.$PATCH'
44
version-resolver:
55
major:
66
labels:
7-
- 'major'
7+
- 'major'
88
minor:
99
labels:
10-
- 'minor'
11-
- 'enhancement'
10+
- 'minor'
11+
- 'enhancement'
1212
patch:
1313
labels:
14-
- 'patch'
15-
- 'fix'
16-
- 'bugfix'
17-
- 'bug'
18-
- 'hotfix'
14+
- 'auto-update'
15+
- 'patch'
16+
- 'fix'
17+
- 'bugfix'
18+
- 'bug'
19+
- 'hotfix'
20+
- 'no-release'
1921
default: 'minor'
2022

2123
categories:
22-
- title: '🚀 Enhancements'
23-
labels:
24-
- 'enhancement'
25-
- title: '🐛 Bug Fixes'
26-
labels:
27-
- 'fix'
28-
- 'bugfix'
29-
- 'bug'
30-
- 'hotfix'
24+
- title: '🚀 Enhancements'
25+
labels:
26+
- 'enhancement'
27+
- 'patch'
28+
- title: '🐛 Bug Fixes'
29+
labels:
30+
- 'fix'
31+
- 'bugfix'
32+
- 'bug'
33+
- 'hotfix'
34+
- title: '🤖 Automatic Updates'
35+
labels:
36+
- 'auto-update'
3137

3238
change-template: |
3339
<details>
@@ -38,3 +44,11 @@ change-template: |
3844
3945
template: |
4046
$CHANGES
47+
48+
replacers:
49+
# Remove irrelevant information from Renovate bot
50+
- search: '/(?<=---\s)\s*^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm'
51+
replace: ''
52+
# Remove Renovate bot banner image
53+
- search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm'
54+
replace: ''

.github/mergify.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# https://docs.mergify.io/conditions.html
2+
# https://docs.mergify.io/actions.html
3+
pull_request_rules:
4+
- name: "approve automated PRs that have passed checks"
5+
conditions:
6+
- "author~=^(cloudpossebot|renovate\\[bot\\])$"
7+
- "base=master"
8+
- "-closed"
9+
- "head~=^(auto-update|renovate)/.*"
10+
- "check-success=test/bats"
11+
- "check-success=test/readme"
12+
- "check-success=test/terratest"
13+
- "check-success=validate-codeowners"
14+
actions:
15+
review:
16+
type: "APPROVE"
17+
bot_account: "cloudposse-mergebot"
18+
message: "We've automatically approved this PR because the checks from the automated Pull Request have passed."
19+
20+
- name: "merge automated PRs when approved and tests pass"
21+
conditions:
22+
- "author~=^(cloudpossebot|renovate\\[bot\\])$"
23+
- "base=master"
24+
- "-closed"
25+
- "head~=^(auto-update|renovate)/.*"
26+
- "check-success=test/bats"
27+
- "check-success=test/readme"
28+
- "check-success=test/terratest"
29+
- "check-success=validate-codeowners"
30+
- "#approved-reviews-by>=1"
31+
- "#changes-requested-reviews-by=0"
32+
- "#commented-reviews-by=0"
33+
actions:
34+
merge:
35+
method: "squash"
36+
37+
- name: "delete the head branch after merge"
38+
conditions:
39+
- "merged"
40+
actions:
41+
delete_head_branch: {}
42+
43+
- name: "ask to resolve conflict"
44+
conditions:
45+
- "conflict"
46+
- "-closed"
47+
actions:
48+
comment:
49+
message: "This pull request is now in conflict. Could you fix it @{{author}}? 🙏"
50+
51+
- name: "remove outdated reviews"
52+
conditions:
53+
- "base=master"
54+
actions:
55+
dismiss_reviews:
56+
changes_requested: true
57+
approved: true
58+
message: "This Pull Request has been updated, so we're dismissing all reviews."
59+
60+
- name: "close Pull Requests without files changed"
61+
conditions:
62+
- "#files=0"
63+
actions:
64+
close:
65+
message: "This pull request has been automatically closed by Mergify because there are no longer any changes."

.github/renovate.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": [
3+
"config:base",
4+
":preserveSemverRanges"
5+
],
6+
"labels": ["auto-update"],
7+
"enabledManagers": ["terraform"],
8+
"terraform": {
9+
"ignorePaths": ["**/context.tf", "examples/**"]
10+
}
11+
}
12+

.github/workflows/auto-context.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "auto-context"
2+
on:
3+
schedule:
4+
# Update context.tf nightly
5+
- cron: '0 3 * * *'
6+
7+
jobs:
8+
update:
9+
if: github.event_name == 'schedule'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Update context.tf
15+
shell: bash
16+
id: update
17+
env:
18+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
19+
run: |
20+
if [[ -f context.tf ]]; then
21+
echo "Discovered existing context.tf! Fetching most recent version to see if there is an update."
22+
curl -o context.tf -fsSL https://raw.githubusercontent.com/cloudposse/terraform-null-label/master/exports/context.tf
23+
if git diff --no-patch --exit-code context.tf; then
24+
echo "No changes detected! Exiting the job..."
25+
else
26+
echo "context.tf file has changed. Update examples and rebuild README.md."
27+
make init
28+
make github/init/context.tf
29+
make readme/build
30+
echo "::set-output name=create_pull_request::true"
31+
fi
32+
else
33+
echo "This module has not yet been updated to support the context.tf pattern! Please update in order to support automatic updates."
34+
fi
35+
36+
- name: Create Pull Request
37+
if: steps.update.outputs.create_pull_request == 'true'
38+
uses: cloudposse/actions/github/[email protected]
39+
with:
40+
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
41+
committer: 'cloudpossebot <[email protected]>'
42+
author: 'cloudpossebot <[email protected]>'
43+
commit-message: Update context.tf from origin source
44+
title: Update context.tf
45+
body: |-
46+
## what
47+
This is an auto-generated PR that updates the `context.tf` file to the latest version from `cloudposse/terraform-null-label`
48+
49+
## why
50+
To support all the features of the `context` interface.
51+
52+
branch: auto-update/context.tf
53+
base: master
54+
delete-branch: true
55+
labels: |
56+
auto-update
57+
context

.github/workflows/auto-format.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Auto Format
2+
on:
3+
pull_request_target:
4+
types: [opened, synchronize]
5+
6+
jobs:
7+
auto-format:
8+
runs-on: ubuntu-latest
9+
container: cloudposse/build-harness:latest
10+
steps:
11+
# Checkout the pull request branch
12+
# "An action in a workflow run can’t trigger a new workflow run. For example, if an action pushes code using
13+
# the repository’s GITHUB_TOKEN, a new workflow will not run even when the repository contains
14+
# a workflow configured to run when push events occur."
15+
# However, using a personal access token will cause events to be triggered.
16+
# We need that to ensure a status gets posted after the auto-format commit.
17+
# We also want to trigger tests if the auto-format made no changes.
18+
- uses: actions/checkout@v2
19+
if: github.event.pull_request.state == 'open'
20+
name: Privileged Checkout
21+
with:
22+
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
23+
repository: ${{ github.event.pull_request.head.repo.full_name }}
24+
# Check out the PR commit, not the merge commit
25+
# Use `ref` instead of `sha` to enable pushing back to `ref`
26+
ref: ${{ github.event.pull_request.head.ref }}
27+
28+
# Do all the formatting stuff
29+
- name: Auto Format
30+
if: github.event.pull_request.state == 'open'
31+
shell: bash
32+
env:
33+
GITHUB_TOKEN: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}"
34+
run: make BUILD_HARNESS_PATH=/build-harness PACKAGES_PREFER_HOST=true -f /build-harness/templates/Makefile.build-harness pr/auto-format/host
35+
36+
# Commit changes (if any) to the PR branch
37+
- name: Commit changes to the PR branch
38+
if: github.event.pull_request.state == 'open'
39+
shell: bash
40+
id: commit
41+
env:
42+
SENDER: ${{ github.event.sender.login }}
43+
run: |
44+
set -x
45+
output=$(git diff --name-only)
46+
47+
if [ -n "$output" ]; then
48+
echo "Changes detected. Pushing to the PR branch"
49+
git config --global user.name 'cloudpossebot'
50+
git config --global user.email '[email protected]'
51+
git add -A
52+
git commit -m "Auto Format"
53+
# Prevent looping by not pushing changes in response to changes from cloudpossebot
54+
[[ $SENDER == "cloudpossebot" ]] || git push
55+
# Set status to fail, because the push should trigger another status check,
56+
# and we use success to indicate the checks are finished.
57+
printf "::set-output name=%s::%s\n" "changed" "true"
58+
exit 1
59+
else
60+
printf "::set-output name=%s::%s\n" "changed" "false"
61+
echo "No changes detected"
62+
fi
63+
64+
- name: Auto Test
65+
uses: cloudposse/actions/github/[email protected]
66+
# match users by ID because logins (user names) are inconsistent,
67+
# for example in the REST API Renovate Bot is `renovate[bot]` but
68+
# in GraphQL it is just `renovate`, plus there is a non-bot
69+
# user `renovate` with ID 1832810.
70+
# Mergify bot: 37929162
71+
# Renovate bot: 29139614
72+
# Cloudpossebot: 11232728
73+
# Need to use space separators to prevent "21" from matching "112144"
74+
if: >
75+
contains(' 37929162 29139614 11232728 ', format(' {0} ', github.event.pull_request.user.id))
76+
&& steps.commit.outputs.changed == 'false' && github.event.pull_request.state == 'open'
77+
with:
78+
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
79+
repository: cloudposse/actions
80+
event-type: test-command
81+
client-payload: |-
82+
{ "slash_command":{"args": {"unnamed": {"all": "all", "arg1": "all"}}},
83+
"pull_request": ${{ toJSON(github.event.pull_request) }},
84+
"github":{"payload":{"repository": ${{ toJSON(github.event.repository) }},
85+
"comment": {"id": ""}
86+
}
87+
}
88+
}

.github/workflows/auto-readme.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "auto-readme"
2+
on:
3+
schedule:
4+
# Example of job definition:
5+
# .---------------- minute (0 - 59)
6+
# | .------------- hour (0 - 23)
7+
# | | .---------- day of month (1 - 31)
8+
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
9+
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
10+
# | | | | |
11+
# * * * * * user-name command to be executed
12+
13+
# Update README.md nightly at 4am UTC
14+
- cron: '0 4 * * *'
15+
16+
jobs:
17+
update:
18+
if: github.event_name == 'schedule'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Update readme
24+
shell: bash
25+
id: update
26+
env:
27+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
28+
run: |
29+
make init
30+
make readme/build
31+
# Ignore changes if they are only whitespace
32+
git diff --ignore-all-space --ignore-blank-lines --quiet README.md && { git restore README.md; echo Ignoring whitespace-only changes in README; }
33+
34+
- name: Create Pull Request
35+
# This action will not create or change a pull request if there are no changes to make.
36+
# If a PR of the auto-update/readme branch is open, this action will just update it, not create a new PR.
37+
uses: cloudposse/actions/github/[email protected]
38+
with:
39+
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
40+
commit-message: Update README.md and docs
41+
title: Update README.md and docs
42+
body: |-
43+
## what
44+
This is an auto-generated PR that updates the README.md and docs
45+
46+
## why
47+
To have most recent changes of README.md and doc from origin templates
48+
49+
branch: auto-update/readme
50+
base: main
51+
delete-branch: true
52+
labels: |
53+
auto-update
54+
no-release
55+
readme

0 commit comments

Comments
 (0)