diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3fda838..db4cccf 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,5 +1,11 @@ name: Docker Push -on: [push, create] +on: + push: + branches: + - master + release: + types: + - created jobs: docker: runs-on: ubuntu-latest diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 0000000..e5403b8 --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,29 @@ +name: Documentation +on: + push: + branches: + - master + release: + types: + - created +jobs: + gh-pages: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: '0.68.2' + extended: true + + - name: Hugo Build + run: make hugo-build + + - name: Push to gh-pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site/public \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a18fd71..6ca40ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,11 @@ name: Test -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + branches: + - master jobs: test: strategy: diff --git a/.gitignore b/.gitignore index 39dd153..a8ada6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .providers +_site \ No newline at end of file diff --git a/Makefile b/Makefile index 097b93d..bbb9726 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ +BASE_PATH := $(realpath -s $(dir $(abspath $(firstword $(MAKEFILE_LIST))))) + # Documentation OUTLINE_CMD ?= outline -DOCUMENTATION_PATH ?= _documentation +DOCUMENTATION_PATH ?= $(BASE_PATH)/_documentation DOCUMENTATION_REFERENCE_PATH ?= $(DOCUMENTATION_PATH)/reference DOCUMENTATION_REFERENCE_TEMPLATE ?= $(DOCUMENTATION_REFERENCE_PATH)/reference.md.tmpl EXAMPLES_PATH ?= starlark/types/testdata/examples @@ -23,9 +25,16 @@ GO_LDFLAGS_PACKAGES = \ starlarkVersion=go.starlark.net \ terraformVersion=github.com/hashicorp/terraform - +# Site +HUGO_SITE_PATH ?= $(BASE_PATH)/_site +HUGO_SITE_CONTENT_PATH ?= $(HUGO_SITE_PATH)/content +HUGO_SITE_TEMPLATE_PATH ?= $(HUGO_SITE_PATH)/themes/hugo-ascode-theme +HUGO_THEME_URL ?= https://github.com/mcuadros/hugo-ascode-theme +HUGO_PARAMS_VERSION ?= dev +export HUGO_PARAMS_VERSION + # Rules -.PHONY: documentation +.PHONY: documentation clean hugo-server documentation: $(RUNTIME_MODULES) $(RUNTIME_MODULES): $(DOCUMENTATION_RUNTIME_PATH) @@ -39,4 +48,23 @@ $(DOCUMENTATION_REFERENCE_PATH): mkdir -p $@ goldflags: - @$(GO_LDFLAGS_CMD) $(GO_LDFLAGS_PACKAGE) . $(GO_LDFLAGS_PACKAGES) \ No newline at end of file + @$(GO_LDFLAGS_CMD) $(GO_LDFLAGS_PACKAGE) . $(GO_LDFLAGS_PACKAGES) + +hugo-build: $(HUGO_SITE_PATH) + hugo --minify --source $(HUGO_SITE_PATH) --config $(DOCUMENTATION_PATH)/config.toml + +hugo-server: $(HUGO_SITE_PATH) + hugo server --source $(HUGO_SITE_PATH) --config $(DOCUMENTATION_PATH)/config.toml + +$(HUGO_SITE_PATH): $(HUGO_SITE_TEMPLATE_PATH) + mkdir -p $@ \ + mkdir -p $(HUGO_SITE_CONTENT_PATH) + mkdir -p $(HUGO_SITE_TEMPLATE_PATH) + ln -s $(DOCUMENTATION_PATH) $(HUGO_SITE_CONTENT_PATH)/docs + ln -s $(DOCUMENTATION_PATH)/_home.md $(HUGO_SITE_CONTENT_PATH)/_index.md + +$(HUGO_SITE_TEMPLATE_PATH): + git clone $(HUGO_THEME_URL) $(HUGO_SITE_TEMPLATE_PATH) + +clean: + rm -rf $(HUGO_SITE_PATH) \ No newline at end of file diff --git a/_documentation/_home.md b/_documentation/_home.md new file mode 100644 index 0000000..6cc6831 --- /dev/null +++ b/_documentation/_home.md @@ -0,0 +1,4 @@ +--- +--- + +AsCode allows you to describe your infrastructure using an expressive language in Terraform without writing a single line of HCL. \ No newline at end of file diff --git a/_documentation/config.toml b/_documentation/config.toml new file mode 100644 index 0000000..8534313 --- /dev/null +++ b/_documentation/config.toml @@ -0,0 +1,47 @@ +baseURL = "ascode.run" +languageCode = "en-us" +title = "AsCode - Terraform Alternative Syntax" +theme = "hugo-ascode-theme" + +pygmentsCodeFences = true +pygmentsCodefencesGuessSyntax = true +pygmentsUseClasses = true + +[[menu.main]] + name = "Home" + url = "/" + weight = 1 + +[[menu.main]] + name = "Docs" + url = "/docs/" + weight = 2 + +[[menu.main]] + name = "GitHub" + url = "https://github.com/mcuadros/ascode" + weight = 3 + +[markup.goldmark.renderer] +unsafe = true +autoHeadingIDType = "github" + +[params] + version="" + google_analytics_id="" + homepage_button_link = '/docs' + homepage_button_text = 'Read The Docs' + homepage_intro = 'AsCode allows you to describe your infrastructure using an expressive language in Terraform without writing a single line of HCL.' + homepage_image = '/images/terminal.gif' + + [params.homepage_meta_tags] + meta_description = "AsCode allows you to describe your infrastructure using an expressive language in Terraform without writing a single line of HCL." + meta_og_title = "AsCode - Terraform Alternative Syntax" + meta_og_type = "website" + meta_og_url = "https://ascode.run" + meta_og_image = "https://ascode.run/images/og.png" + meta_og_description = "AsCode - Terraform Alternative Syntax." + + [params.logo] + mobile = "/images/logo-mobile.svg" + standard = "/images/logo.svg" diff --git a/_documentation/getting-started.md b/_documentation/getting-started.md index 6136b09..151a80e 100644 --- a/_documentation/getting-started.md +++ b/_documentation/getting-started.md @@ -1,6 +1,6 @@ --- title: 'Getting Started' weight: 2 ----- +--- TODO \ No newline at end of file diff --git a/_documentation/github-action.md b/_documentation/github-action.md index 3aa1b3d..2db0a85 100644 --- a/_documentation/github-action.md +++ b/_documentation/github-action.md @@ -1,6 +1,6 @@ --- title: 'GitHub Action' weight: 40 ----- +--- TODO \ No newline at end of file diff --git a/_scripts/template.md b/_scripts/template.md deleted file mode 100644 index 5908671..0000000 --- a/_scripts/template.md +++ /dev/null @@ -1,140 +0,0 @@ -{{- define "functionName" }} -{{- if ne .Receiver "types" -}} -# -{{- end -}} -### def {{ if ne .Receiver "types" -}} - {{ .Receiver }}. - {{- end -}} - {{- (index (split .Signature "(") 0) -}} -{{- end -}} -{{- define "function" }} - -{{ template "functionName" . }} -```go -{{if ne .Receiver "types" -}}{{.Receiver}}.{{- end }}{{ .Signature }} -``` - -{{- if ne .Description "" }} -{{ .Description }} -{{- end -}} - -{{- if gt (len .Params) 0 }} - -###### Arguments - -| name | type | description | -|------|------|-------------| -{{ range .Params -}} -| `{{ .Name }}` | `{{ .Type }}` | {{ (replace_all .Description "\n" "") }} | -{{ end -}} - -{{- end -}} - -{{- if gt (len .Examples) 0 }} -###### Examples -{{ range .Examples -}} -{{ .Description }} -```python -{{ .Code }} -``` -{{ end -}} - -{{- end -}} - -{{- end -}} -{{- define "indexFunctionName" -}} -{{- $receiver := "" -}} -{{ if ne .Receiver "types" -}}{{ $receiver = printf "%s." .Receiver }}{{- end -}} -{{- $name := printf "def %s" (index (split .Signature "(") 0) -}} -{{- $anchor := printf "def %s%s" $receiver (index (split .Signature "(") 0) -}} -* [{{ $name }}({{ (index (split .Signature "(") 1) }}](#{{ sanitizeAnchor $anchor }}) -{{- end -}} - -{{- define "index" -}} -## Index -
-{{ range .Functions }} -{{ template "indexFunctionName" . }} -{{- end -}} -{{ range .Types -}} -{{ $name := printf "type %s" .Name }} -* [{{ $name }}](#{{ sanitizeAnchor $name }}) -{{- range .Methods }} - {{ template "indexFunctionName" . -}} -{{- end -}} -{{- end }} -
-{{ end -}} - - -{{- range . -}} ---- -title: '{{ .Path }}' ---- - -{{ if ne .Description "" }}{{ .Description }}{{ end }} - -{{ template "index" . }} - - -{{- if gt (len .Functions) 0 }} -## Functions -{{ range .Functions -}} -{{ template "function" . }} -{{ end -}} -{{- end }} - -{{ if gt (len .Types) 0 }} -## Types -{{ range .Types -}} - - -### type {{ .Name }} -{{ if ne .Description "" }}{{ .Description }}{{ end -}} -{{ if gt (len .Fields) 0 }} - -###### Properties - -| name | type | description | -|------|------|-------------| -{{ range .Fields -}} -| `{{ .Name }}` | `{{ .Type }}` | {{ (replace_all .Description "\n" "") }} | -{{ end -}} - -{{ end }} - -{{ if gt (len .Examples) 0 }} -###### Examples -{{ range .Examples -}} -{{ .Description }} -```python -{{ .Code }} -``` -{{ end -}} - - -{{ end -}} - -{{ if gt (len .Methods) 0 }} - -###### Methods - -{{- range .Methods -}} -{{ template "function" . }} -{{ end -}} -{{- if gt (len .Operators) 0 }} - -###### Operators - -| operator | description | -|----------|-------------| -{{ range .Operators -}} - | {{ .Opr }} | {{ .Description }} | -{{ end }} - -{{ end }} - -{{ end }} -{{- end -}} -{{- end -}} -{{ end }} \ No newline at end of file