Skip to content

Commit c9f7672

Browse files
authored
feat: add iam_member resource and uodate GH actions (#11)
1 parent 6c83a5b commit c9f7672

13 files changed

+229
-34
lines changed

.github/auto-release.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: '$RESOLVED_VERSION'
3+
version-template: '$MAJOR.$MINOR.$PATCH'
4+
version-resolver:
5+
major:
6+
labels:
7+
- 'major'
8+
minor:
9+
labels:
10+
- 'minor'
11+
- 'enhancement'
12+
- 'feat'
13+
patch:
14+
labels:
15+
- 'auto-update'
16+
- 'patch'
17+
- 'fix'
18+
- 'bugfix'
19+
- 'bug'
20+
- 'hotfix'
21+
- 'refactor'
22+
- 'ci'
23+
- 'build'
24+
- 'docs'
25+
- 'test'
26+
- 'chore'
27+
default: 'minor'
28+
29+
categories:
30+
- title: '🚀 Enhancements'
31+
labels:
32+
- 'minor'
33+
- 'enhancement'
34+
- 'feat'
35+
- title: '🐛 Bug Fixes'
36+
labels:
37+
- 'auto-update'
38+
- 'patch'
39+
- 'fix'
40+
- 'bugfix'
41+
- 'bug'
42+
- 'hotfix'
43+
- 'refactor'
44+
- 'ci'
45+
- 'build'
46+
- 'docs'
47+
- 'test'
48+
- 'chore'
49+
- title: '🤖 Automatic Updates'
50+
labels:
51+
- 'auto-update'
52+
53+
change-template: |
54+
<details>
55+
<summary>$TITLE @$AUTHOR (#$NUMBER)</summary>
56+
$BODY
57+
</details>
58+
template: |
59+
$CHANGES

.github/labeler.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: v1
2+
3+
labels:
4+
- label: "feat"
5+
matcher:
6+
title: "^feat:.*"
7+
- label: "fix"
8+
matcher:
9+
title: "^fix:.*"
10+
- label: "ci"
11+
matcher:
12+
title: "^ci:.*"
13+
- label: "chore"
14+
matcher:
15+
title: "^chore:.*"
16+
- label: "build"
17+
matcher:
18+
title: "^build:.*"
19+
- label: "docs"
20+
matcher:
21+
title: "^docs:.*"
22+
- label: "refactor"
23+
matcher:
24+
title: "^refactor:.*"
25+
- label: "test"
26+
matcher:
27+
title: "^test:.*"

.github/labels.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
# Default GitHub labels
3+
- color: d73a4a
4+
name: bug
5+
description: Something isn't working
6+
- color: cfd3d7
7+
name: duplicate
8+
description: This issue or pull request already exists
9+
- color: a2eeef
10+
name: enhancement
11+
description: New feature or request
12+
- color: 7057ff
13+
name: good first issue
14+
description: Good for newcomers
15+
- color: 008672
16+
name: help wanted
17+
description: Extra attention is needed
18+
- color: e4e669
19+
name: invalid
20+
description: This doesn't seem right
21+
- color: d876e3
22+
name: question
23+
description: Further information is requested
24+
- color: ffffff
25+
name: wontfix
26+
description: This will not be worked on
27+
28+
- color: a0040c
29+
name: no-pr-activity
30+
description: stalled PR
31+
- color: d93f0b
32+
name: no-issue-activity
33+
description: stalled issue
34+
- color: f9dcbd
35+
name: build
36+
description: Changes that affect the build system or external dependencies
37+
- color: 63dae2
38+
name: ci
39+
description: Changes to our CI configuration files and scripts
40+
- color: 6e93e5
41+
name: docs
42+
description: Documentation only changes
43+
- color: 5edb3f
44+
name: feat
45+
description: A new feature
46+
- color: 58e8c8
47+
name: fix
48+
description: A bug fix
49+
- color: efada0
50+
name: refactor
51+
description: A code change that neither fixes a bug nor adds a feature
52+
- color: 1d76db
53+
name: test
54+
description: Adding missing tests or correcting existing tests
55+
- color: dfb443
56+
name: chore
57+
description: Adding missing tests or correcting existing tests

.github/workflows/docs.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Generate terraform docs
22
on:
3-
- pull_request
3+
pull_request_target:
4+
45
jobs:
56
docs:
67
runs-on: ubuntu-latest

.github/workflows/labeler.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Auto Label
2+
on:
3+
pull_request_target:
4+
5+
jobs:
6+
labeler:
7+
name: Labeler
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: fuxingloh/[email protected]
11+
with:
12+
github-token: ${{ secrets.GITHUB_TOKEN }}
13+
config-path: .github/labeler.yml

.github/workflows/labels.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Sync labels in the declarative way
3+
on:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/[email protected]
12+
- uses: micnncim/[email protected]
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
GITHUB_REPOSITORY: ${{ github.repository }}
16+
with:
17+
manifest: .github/labels.yml

.github/workflows/pr-lint.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
name: Lint PR
22
on:
3-
pull_request:
4-
types:
5-
- opened
6-
- reopened
7-
- edited
8-
- synchronize
3+
pull_request_target:
94

105
jobs:
116
main:
@@ -38,3 +33,4 @@ jobs:
3833
* **refactor**: A code change that neither fixes a bug nor adds a feature
3934
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
4035
* **test**: Adding missing tests or correcting existing tests
36+
* **chore**: No production code change

.github/workflows/release.yml

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
name: Release
1+
2+
name: Release Drafter
3+
24
on:
35
push:
4-
tags:
5-
- "v*"
6+
branches:
7+
- master
8+
69
jobs:
7-
release-notary:
8-
name: Release-notary
10+
publish:
911
runs-on: ubuntu-latest
1012
steps:
11-
- name: Check out code
12-
uses: actions/checkout@v2
13-
14-
- name: Release Notary Action
15-
uses: commitsar-app/[email protected]
16-
env:
17-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
# Drafts your next Release notes as Pull Requests are merged into "master"
14+
- uses: release-drafter/release-drafter@v5
15+
with:
16+
publish: true
17+
prerelease: false
18+
config-name: auto-release.yml
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/stale.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Mark stale issues and pull requests
2+
3+
on:
4+
schedule:
5+
- cron: "0 12 * * *"
6+
7+
jobs:
8+
stale:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/stale@v1
14+
with:
15+
repo-token: ${{ secrets.GITHUB_TOKEN }}
16+
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
17+
stale-pr-message: 'This pull-request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
18+
stale-issue-label: 'no-issue-activity'
19+
stale-pr-label: 'no-pr-activity'
20+
days-before-stale: 30
21+
days-before-close: 5

.github/workflows/terraform.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
name: 'Validate TF manifests'
22
on:
3-
- pull_request
3+
pull_request_target:
4+
45
jobs:
56
terraform:
67
name: Terraform
78
runs-on: ubuntu-latest
89
steps:
910
- name: Checkout
10-
uses: actions/checkout@v2
11+
uses: actions/checkout@master
1112

1213
- name: Terraform
1314
uses: hashicorp/setup-terraform@v1

examples/basic/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ terraform {
55
version = ">= 3.0"
66
}
77
}
8-
required_version = ">= 0.13"
8+
required_version = ">= 0.14"
99
}

main.tf

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
locals {
22
service_account_key_enabled = module.this.enabled && var.create_service_account_key
3+
iam_policy_enabled = module.this.enabled && length(var.roles) > 0
4+
iam_policy_count = module.this.enabled && length(var.roles) > 0 ? length(var.roles) : 0
35
}
46

57
resource "google_service_account" "default" {
6-
count = module.this.enabled ? 1 : 0
8+
count = module.this.enabled ? 1 : 0
9+
710
account_id = module.this.id
811
display_name = module.this.id
912
description = var.description
1013
project = var.project
1114
}
1215

1316
resource "google_service_account_key" "default" {
14-
count = local.service_account_key_enabled ? 1 : 0
17+
count = local.service_account_key_enabled ? 1 : 0
18+
1519
service_account_id = join("", google_service_account.default.*.name)
1620
key_algorithm = var.key_algorithm
1721
public_key_type = var.public_key_type
@@ -20,14 +24,10 @@ resource "google_service_account_key" "default" {
2024
keepers = var.keepers
2125
}
2226

23-
data "google_iam_policy" "default" {
24-
count = module.this.enabled ? 1 : 0
27+
resource "google_project_iam_member" "default" {
28+
count = local.iam_policy_count
2529

26-
dynamic "binding" {
27-
for_each = toset(var.roles)
28-
content {
29-
role = binding.key
30-
members = [format("serviceAccount:%s", join("", google_service_account.default.*.email))]
31-
}
32-
}
30+
project = var.project
31+
role = var.roles[count.index]
32+
member = format("serviceAccount:%s", join("", google_service_account.default.*.email))
3333
}

versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ terraform {
55
version = ">= 3.0"
66
}
77
}
8-
required_version = ">= 0.13"
8+
required_version = ">= 0.14"
99
}

0 commit comments

Comments
 (0)