-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Adding terraform-docs.
Showing
9 changed files
with
336 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- | ||
# This workflow uses actions that are not certified by GitHub. They are provided | ||
# by a third-party and are governed by separate terms of service, privacy | ||
# policy, and support documentation. | ||
|
||
################################################################################ | ||
# DO NOT EDIT THIS FILE! | ||
# | ||
# 1. Edit the *.gotmpl.yml files instead. | ||
# 2. Run 'go run generate-workflow.go -p {package} -t {template}'. | ||
################################################################################ | ||
|
||
name: Build terraform-docs | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
paths: | ||
- ".github/workflows/build-terraform-docs.yml" | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- ".github/workflows/build-terraform-docs.yml" | ||
schedule: | ||
- cron: '30 14 * * *' | ||
|
||
# Variables available to all jobs defined in this file | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
REGISTRY: ${{ vars.REGISTRY }} | ||
|
||
# Declare default permissions as read only. | ||
permissions: read-all | ||
|
||
jobs: | ||
lookup: | ||
runs-on: ubuntu-latest | ||
name: Lookup current version | ||
permissions: | ||
packages: write | ||
contents: read | ||
strategy: | ||
fail-fast: false | ||
|
||
container: | ||
image: ghcr.io/northwood-labs/package-builder/ubuntu-v22.04:latest | ||
credentials: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
outputs: | ||
cache_hit: ${{ steps.check.outputs.cache-hit }} | ||
package_version: ${{ steps.lookup_version.outputs.package_version }} | ||
|
||
steps: | ||
- name: Lookup latest version of package | ||
id: lookup_version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "package_version=$(download-asset latest-tag -r terraform-docs/terraform-docs -s)" >> $GITHUB_OUTPUT | ||
- name: Check to see if we've already built this version | ||
uses: actions/cache/restore@v4 | ||
id: check | ||
with: | ||
key: "tenv-${{ steps.lookup_version.outputs.package_version }}" | ||
path: "packages/terraform-docs/dist" | ||
lookup-only: true | ||
|
||
build: | ||
if: needs.lookup.outputs.cache_hit != 'true' | ||
needs: lookup | ||
name: Build and cache | ||
uses: northwood-labs/package-building/.github/workflows/build-and-cache.yml@main | ||
secrets: inherit | ||
with: | ||
package-name: "terraform-docs" | ||
package-version: ${{ needs.lookup.outputs.package_version }} | ||
|
||
upload: | ||
if: needs.lookup.outputs.cache_hit != 'true' | ||
needs: build | ||
name: Upload to S3 | ||
uses: northwood-labs/package-building/.github/workflows/upload-to-s3.yml@main | ||
secrets: inherit | ||
with: | ||
package-name: "terraform-docs" | ||
package-version: ${{ needs.lookup.outputs.package_version }} | ||
|
||
metadata: | ||
if: needs.lookup.outputs.cache_hit != 'true' | ||
needs: upload | ||
name: Generate metadata | ||
uses: northwood-labs/package-building/.github/workflows/generate-rpm-meta.yml@main | ||
secrets: inherit |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
# This workflow uses actions that are not certified by GitHub. They are provided | ||
# by a third-party and are governed by separate terms of service, privacy | ||
# policy, and support documentation. | ||
|
||
{{ .DoNotEdit }} | ||
|
||
name: Build {{ .Package }} | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
paths: | ||
- ".github/workflows/build-{{ .Package }}.yml" | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- ".github/workflows/build-{{ .Package }}.yml" | ||
schedule: | ||
- cron: '{{ .CronExpr }}' | ||
|
||
# Variables available to all jobs defined in this file | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
REGISTRY: {{ "${{" }} vars.REGISTRY {{ "}}" }} | ||
|
||
# Declare default permissions as read only. | ||
permissions: read-all | ||
|
||
jobs: | ||
lookup: | ||
runs-on: ubuntu-latest | ||
name: Lookup current version | ||
permissions: | ||
packages: write | ||
contents: read | ||
strategy: | ||
fail-fast: false | ||
|
||
container: | ||
image: ghcr.io/northwood-labs/package-builder/ubuntu-v22.04:latest | ||
credentials: | ||
username: {{ "${{" }} github.actor {{ "}}" }} | ||
password: {{ "${{" }} secrets.GITHUB_TOKEN {{ "}}" }} | ||
|
||
outputs: | ||
cache_hit: {{ "${{" }} steps.check.outputs.cache-hit {{ "}}" }} | ||
package_version: {{ "${{" }} steps.lookup_version.outputs.package_version {{ "}}" }} | ||
|
||
steps: | ||
- name: Lookup latest version of package | ||
id: lookup_version | ||
env: | ||
GITHUB_TOKEN: {{ "${{" }} secrets.GITHUB_TOKEN {{ "}}" }} | ||
run: | | ||
echo "package_version=$(download-asset latest-tag -r {{ .OwnerRepo }} -s)" >> $GITHUB_OUTPUT | ||
- name: Check to see if we've already built this version | ||
uses: actions/cache/restore@v4 | ||
id: check | ||
with: | ||
key: "tenv-{{ "${{" }} steps.lookup_version.outputs.package_version {{ "}}" }}" | ||
path: "packages/{{ .Package }}/dist" | ||
lookup-only: true | ||
|
||
build: | ||
if: needs.lookup.outputs.cache_hit != 'true' | ||
needs: lookup | ||
name: Build and cache | ||
uses: northwood-labs/package-building/.github/workflows/build-and-cache.yml@main | ||
secrets: inherit | ||
with: | ||
package-name: "{{ .Package }}" | ||
package-version: {{ "${{" }} needs.lookup.outputs.package_version {{ "}}" }} | ||
|
||
upload: | ||
if: needs.lookup.outputs.cache_hit != 'true' | ||
needs: build | ||
name: Upload to S3 | ||
uses: northwood-labs/package-building/.github/workflows/upload-to-s3.yml@main | ||
secrets: inherit | ||
with: | ||
package-name: "{{ .Package }}" | ||
package-version: {{ "${{" }} needs.lookup.outputs.package_version {{ "}}" }} | ||
|
||
metadata: | ||
if: needs.lookup.outputs.cache_hit != 'true' | ||
needs: upload | ||
name: Generate metadata | ||
uses: northwood-labs/package-building/.github/workflows/generate-rpm-meta.yml@main | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"flag" | ||
"fmt" | ||
"io" | ||
"os" | ||
"strings" | ||
"text/template" | ||
|
||
"github.com/goware/prefixer" | ||
"github.com/lithammer/dedent" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
var ( | ||
fCronExpr string | ||
fOwnerRepo string | ||
fPackage string | ||
fTemplate string | ||
|
||
dockerfile *template.Template | ||
|
||
doNotEditWarning = strings.TrimSpace(dedent.Dedent(` | ||
DO NOT EDIT THIS FILE! | ||
1. Edit the *.gotmpl.yml files instead. | ||
2. Run 'go run generate-workflow.go -p {package} -t {template}'. | ||
`)) | ||
) | ||
|
||
func init() { | ||
flag.StringVar(&fCronExpr, "c", "", "The cron expression for a scheduled build.") | ||
flag.StringVar(&fOwnerRepo, "r", "", "The GitHub owner/repo to lookup.") | ||
flag.StringVar(&fPackage, "p", "", "The name of the package to create stubs for.") | ||
flag.StringVar(&fTemplate, "t", "", "The name of the template file to use.") | ||
|
||
flag.Parse() | ||
} | ||
|
||
func main() { | ||
dockerfile = template.Must(template.ParseFiles(fTemplate)) | ||
|
||
dockerfileFile, err := os.Create(fmt.Sprintf(".github/workflows/build-%s.yml", fPackage)) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Do some magic to convert the DO NOT EDIT warning into a valid Dockerfile comment. | ||
buf := bytes.NewBufferString(doNotEditWarning) | ||
prefixReader := prefixer.New(buf, "# ") | ||
|
||
commentedBuf, err := io.ReadAll(prefixReader) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
doNotEditStringValue := strings.TrimSpace(dedent.Dedent(` | ||
################################################################################ | ||
%s | ||
################################################################################ | ||
`)) | ||
|
||
// Take the template, execute it using variables we pass-in from the | ||
// JSON config, and write the result to the new Dockerfile. | ||
err = dockerfile.Execute(dockerfileFile, map[string]interface{}{ | ||
"CronExpr": fCronExpr, | ||
"OwnerRepo": fOwnerRepo, | ||
"Package": fPackage, | ||
"DoNotEdit": fmt.Sprintf(doNotEditStringValue, string(commentedBuf)), | ||
}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module gen | ||
|
||
go 1.22.1 | ||
|
||
require ( | ||
github.com/goware/prefixer v0.0.0-20160118172347-395022866408 | ||
github.com/lithammer/dedent v1.1.0 | ||
github.com/sirupsen/logrus v1.9.3 | ||
) | ||
|
||
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/goware/prefixer v0.0.0-20160118172347-395022866408 h1:Y9iQJfEqnN3/Nce9cOegemcy/9Ai5k3huT6E80F3zaw= | ||
github.com/goware/prefixer v0.0.0-20160118172347-395022866408/go.mod h1:PE1ycukgRPJ7bJ9a1fdfQ9j8i/cEcRAoLZzbxYpNB/s= | ||
github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffktY= | ||
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= | ||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= | ||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
# https://goreleaser.com/customization/project/ | ||
project_name: terraform-docs | ||
|
||
variables: | ||
Vendor: terraform-docs authors | ||
VendorHomepage: https://terraform-docs.io | ||
License: MIT | ||
Description: | | ||
A utility to generate documentation from Terraform modules in various output formats. | ||
# https://goreleaser.com/customization/includes/ | ||
includes: | ||
- from_file: | ||
path: ../shared.yml | ||
|
||
# https://goreleaser.com/customization/hooks/ | ||
before: | ||
hooks: | ||
- cmd: | | ||
bash ./download.sh | ||
output: true | ||
dir: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# linux/amd64 (Intel64) | ||
download-asset get \ | ||
--owner-repo "terraform-docs/terraform-docs" \ | ||
--pattern "terraform-docs-v{{.Ver}}-linux-amd64.{{.Ext}}" \ | ||
--archive-path "terraform-docs" \ | ||
--write-to-bin "terraform-docs_amd64" \ | ||
; | ||
|
||
# linux/arm64 (ARM64) | ||
download-asset get \ | ||
--owner-repo "terraform-docs/terraform-docs" \ | ||
--pattern "terraform-docs-v{{.Ver}}-linux-arm64.{{.Ext}}" \ | ||
--archive-path "terraform-docs" \ | ||
--write-to-bin "terraform-docs_arm64" \ | ||
; |