Skip to content

Commit b3576cd

Browse files
committed
add:provider
1 parent c4ac657 commit b3576cd

File tree

16 files changed

+343
-8
lines changed

16 files changed

+343
-8
lines changed

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Fetch GitHub App Token
16+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
17+
id: token
18+
with:
19+
app-id: ${{ vars.GH_APP_TAGPR_ID }}
20+
private-key: ${{ secrets.GH_APP_TAGPR_PKEY }}
21+
22+
- name: Checkout
23+
uses: actions/checkout@v5
24+
25+
- name: Set up Go
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version-file: 'go.mod'
29+
cache: true
30+
31+
- name: Import GPG key
32+
uses: crazy-max/ghaction-import-gpg@v6
33+
id: import_gpg
34+
with:
35+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
36+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
37+
38+
- name: Run GoReleaser
39+
uses: goreleaser/goreleaser-action@v6
40+
with:
41+
version: latest
42+
args: release --clean
43+
env:
44+
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
45+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.github/workflows/tagpr.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: tagpr
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
actions: write
12+
13+
jobs:
14+
tagpr:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Fetch GitHub App Token
18+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
19+
id: token
20+
with:
21+
app-id: ${{ secrets.GH_APP_TAGPR_ID }}
22+
private-key: ${{ secrets.GH_APP_TAGPR_PKEY }}
23+
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
token: ${{ steps.token.outputs.token }}
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version-file: 'go.mod'
33+
cache: true
34+
35+
- name: Run tagpr
36+
uses: Songmu/tagpr@v1
37+
env:
38+
GITHUB_TOKEN: ${{ steps.token.outputs.token }}

.github/workflows/test.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version-file: 'go.mod'
25+
cache: true
26+
27+
- name: Download dependencies
28+
run: go mod download
29+
30+
- name: Run go fmt
31+
run: |
32+
if [ -n "$(go fmt ./...)" ]; then
33+
echo "Please run 'go fmt ./...'"
34+
exit 1
35+
fi
36+
37+
- name: Run go vet
38+
run: go vet ./...
39+
40+
- name: Run tests
41+
run: go test -v -race ./...
42+
43+
test-acc:
44+
runs-on: ubuntu-latest
45+
if: github.event_name == 'pull_request'
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
50+
- name: Set up Go
51+
uses: actions/setup-go@v5
52+
with:
53+
go-version-file: 'go.mod'
54+
cache: true
55+
56+
- name: Download dependencies
57+
run: go mod download
58+
59+
- name: Run acceptance tests
60+
env:
61+
TF_ACC: "1"
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
GITHUB_OWNER: ${{ github.repository_owner }}
64+
run: go test -v -timeout 30m ./internal/provider/...

.goreleaser.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
builds:
2+
- env:
3+
- CGO_ENABLED=0
4+
mod_timestamp: '{{ .CommitTimestamp }}'
5+
flags:
6+
- -trimpath
7+
ldflags:
8+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
9+
goos:
10+
- freebsd
11+
- windows
12+
- linux
13+
- darwin
14+
goarch:
15+
- amd64
16+
- '386'
17+
- arm
18+
- arm64
19+
ignore:
20+
- goos: darwin
21+
goarch: '386'
22+
main: ./cmd/terraform-provider-kwgithub
23+
binary: '{{ .ProjectName }}_v{{ .Version }}'
24+
archives:
25+
- format: zip
26+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
27+
checksum:
28+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
29+
algorithm: sha256
30+
signs:
31+
- artifacts: checksum
32+
args:
33+
- "--batch"
34+
- "--local-user"
35+
- "{{ .Env.GPG_FINGERPRINT }}"
36+
- "--output"
37+
- "${signature}"
38+
- "--detach-sign"
39+
- "${artifact}"
40+
release:
41+
changelog:
42+
sort: asc
43+
filters:
44+
exclude:
45+
- '^docs:'
46+
- '^test:'

.tagpr

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# tagpr - tag pull request based release flow
2+
# https://github.com/Songmu/tagpr
3+
4+
[tagpr]
5+
# versioning rule. available: "git" or "semver"
6+
versionFile = "-"
7+
vPrefix = true
8+
releaseBranch = "main"
9+
changelog = true
10+
command = "make build"
11+
12+
# Major release branch prefix
13+
# When you create a branch with this prefix, tagpr will create a major release
14+
# e.g. "release/v1", "release/v2"
15+
majorBranchPrefix = "release/v"
16+
17+
# Release commit message template
18+
# Available variables: {{.Version}}, {{.PrevVersion}}, {{.Changelog}}
19+
releaseCommit = "Release {{.Version}}"
20+
21+
# Release body template for GitHub Release
22+
# Available variables: {{.Version}}, {{.PrevVersion}}, {{.Changelog}}
23+
releaseBody = |
24+
## {{.Version}}
25+
26+
{{.Changelog}}

aqua.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
# aqua - Declarative CLI Version Manager
3+
# https://aquaproj.github.io/
4+
# checksum:
5+
# enabled: true
6+
# require_checksum: true
7+
# supported_envs:
8+
# - all
9+
registries:
10+
- type: standard
11+
ref: v4.305.0 # renovate: depName=aquaproj/aqua-registry
12+
packages:
13+
- name: hashicorp/[email protected]
14+
- name: terraform-docs/[email protected]

cmd/terraform-provider-kwgithub/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func main() {
1212
err := providerserver.Serve(context.Background(), provider.New, providerserver.ServeOpts{
13-
Address: "knowledge-work/kwgithub",
13+
Address: "registry.terraform.io/knowledge-work/kw-github",
1414
})
1515
if err != nil {
1616
log.Fatal(err)

docs/index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "kwgithub Provider"
4+
description: |-
5+
The KW GitHub provider is used to interact with GitHub resources specific to Knowledge Work organization.
6+
---
7+
8+
# kwgithub Provider
9+
10+
The KW GitHub provider is used to interact with GitHub resources specific to Knowledge Work organization.
11+
12+
## Example Usage
13+
14+
```terraform
15+
provider "kwgithub" {
16+
token = var.github_token
17+
}
18+
```
19+
20+
<!-- schema generated by tfplugindocs -->
21+
## Schema
22+
23+
### Optional
24+
25+
- `github_base_url` (String) GitHub base URL. Defaults to https://api.github.com. Can also be set via GITHUB_BASE_URL environment variable.
26+
- `token` (String, Sensitive) GitHub personal access token. Can also be set via GITHUB_TOKEN environment variable.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "kwgithub_ruleset_allowed_merge_methods Resource - kwgithub"
4+
subcategory: ""
5+
description: |-
6+
Manages allowed merge methods for a GitHub repository ruleset.
7+
---
8+
9+
# kwgithub_ruleset_allowed_merge_methods (Resource)
10+
11+
Manages allowed merge methods for a GitHub repository ruleset.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "kwgithub_ruleset_allowed_merge_methods" "example" {
17+
repository = "owner/repo"
18+
ruleset_id = "12345"
19+
allowed_merge_methods = ["merge", "squash", "rebase"]
20+
}
21+
```
22+
23+
<!-- schema generated by tfplugindocs -->
24+
## Schema
25+
26+
### Required
27+
28+
- `allowed_merge_methods` (Set of String) Set of allowed merge methods. Valid values are: 'merge', 'squash', 'rebase'.
29+
- `repository` (String) The name of the repository (e.g., 'owner/repo').
30+
- `ruleset_id` (String) The ID of the ruleset to manage.
31+
32+
### Optional
33+
34+
- `force_update` (String) Timestamp to force update when dependent resources change. Set this to a new value (e.g., timestamp) when you want to force an update.
35+
36+
### Read-Only
37+
38+
- `id` (String) The ID of this resource.

examples/provider/provider.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "kwgithub" {
2+
token = var.github_token
3+
}

0 commit comments

Comments
 (0)