Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Organization's .github README.md.gotmpl #368

Merged
merged 30 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
14d8a00
Fetch org readme template
osterman Jan 25, 2024
45e498c
chore: update repo banner image
actions-user Jan 25, 2024
33ae644
fetch template from main
osterman Jan 25, 2024
b87b954
add safe directory for git
osterman Jan 25, 2024
80e004a
add safe directory for git
osterman Jan 25, 2024
cd6f93c
add safe directory for git
osterman Jan 25, 2024
4eb3dcd
test fix
osterman Jan 25, 2024
dd7ad68
test fix
osterman Jan 25, 2024
47dd597
test fix
osterman Jan 25, 2024
ad0db3d
test fix
osterman Jan 25, 2024
abfe9be
test fix
osterman Jan 25, 2024
8fe14aa
test fix
osterman Jan 25, 2024
765605a
test fix
osterman Jan 25, 2024
9e09948
test fix
osterman Jan 25, 2024
dadca12
use make native
osterman Jan 25, 2024
c56a649
fix lint error
osterman Jan 25, 2024
ee9eb05
bump checkout
osterman Jan 25, 2024
18f8d06
bump checkout and do not ignore .git
osterman Jan 25, 2024
3f18ad2
Update tool versions, fix Docker build on Apple Silicon (#369)
Nuru Jan 26, 2024
ef1f8f9
formatting
osterman Jan 26, 2024
db98b44
remove -# syntax=docker/dockerfile:1.3
osterman Jan 26, 2024
0682540
Merge branch 'master' into org-readme-templates
osterman Jan 26, 2024
b025620
move README_TEMPLATE_YAML dep and check for .git
osterman Jan 26, 2024
68e4151
Update lint for security
Nuru Jan 26, 2024
a86c871
Restrict README template to whitelisted orgs
Nuru Jan 26, 2024
2f06dbe
terminology
Nuru Jan 26, 2024
a9ba65e
Do not allow override of remote URL
Nuru Jan 26, 2024
e13a7e6
Fix (spurious) lint complaint
Nuru Jan 26, 2024
406ee3f
Better error message
Nuru Jan 26, 2024
0d94a27
Merge branch 'master' into org-readme-templates
osterman Jan 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.git/*
vendor/*
7 changes: 6 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ jobs:
name: readme
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Fix git safe.directory when run inside container
# https://github.com/actions/runner/issues/2033
run: |
mkdir -p /home/runner/work/_temp/_github_home
printf "[safe]\n\tdirectory = /github/workspace" > /home/runner/work/_temp/_github_home/.gitconfig
osterman marked this conversation as resolved.
Show resolved Hide resolved
- uses: docker://cloudposse/build-harness:latest
with:
entrypoint: /usr/bin/make
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.project
build-harness.iml
build-harness
templates/README.md.gotmpl
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1.20.13-alpine3.18

LABEL maintainer="Cloud Posse <[email protected]>"

LABEL "com.github.actions.name"="Build Harness"
Expand Down Expand Up @@ -81,13 +82,15 @@ RUN update-alternatives --set terraform /usr/share/terraform/$DEFAULT_TERRAFORM_

# Install tflint
RUN curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash

COPY <<EOF /root/.tflint.hcl
plugin "aws" {
enabled = true
version = "0.26.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
EOF

RUN tflint --init

# Patch for old Makefiles that expect a directory like x.x from the 0.x days.
Expand Down
33 changes: 29 additions & 4 deletions modules/readme/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
export README_LINT ?= $(TMP)/README.md
export README_FILE ?= README.md
export README_YAML ?= README.yaml

export README_TEMPLATE_REPO_REMOTE_NAME ?= origin
export README_TEMPLATE_REPO_REMOTE ?= $(shell [ -d .git ] && git remote get-url $(README_TEMPLATE_REPO_REMOTE_NAME))

# Parse https://github.com/...
ifneq (,$(findstring https://github.com/,$(README_TEMPLATE_REPO_REMOTE)))
URL_NO_PROTOCOL := $(subst https://github.com/,,$(README_TEMPLATE_REPO_REMOTE))
README_TEMPLATE_REPO_ORG ?= $(firstword $(subst /, ,$(URL_NO_PROTOCOL)))
endif

# Parse [email protected]:...
ifneq (,$(findstring [email protected]:,$(README_TEMPLATE_REPO_REMOTE)))
URL_NO_GIT := $(subst [email protected]:,,$(README_TEMPLATE_REPO_REMOTE))
README_TEMPLATE_REPO_ORG ?= $(firstword $(subst /, ,$(URL_NO_GIT)))
endif

export README_TEMPLATE_REPO ?= .github
export README_TEMPLATE_REPO_REF ?= blob/main
export README_TEMPLATE_REPO_PATH ?= README.md.gotmpl
export README_TEMPLATE_REPO_URL ?= https://github.com/$(README_TEMPLATE_REPO_ORG)/$(README_TEMPLATE_REPO)/$(README_TEMPLATE_REPO_REF)/$(README_TEMPLATE_REPO_PATH)?raw=true
export README_TEMPLATE_FILE ?= $(BUILD_HARNESS_PATH)/templates/README.md.gotmpl
export README_TEMPLATE_YAML := $(if $(findstring http,$(README_YAML)),$(README_YAML),$(BUILD_HARNESS_PATH)/templates/$(README_YAML))
export README_INCLUDES ?= $(file://$(shell pwd)/?type=text/plain)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nuru this is needed by the README.md.gotmpl which uses it as the base for including other files (e.g. from docs/)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this syntax, README_INCLUDES is always empty. Probably meant for it to be automatically including $PWD but since it never worked, I would rather just remove it from the template.


# Create the README.md.gotmpl, if none exists by fetching it from the organization's `.github` repository
$(README_TEMPLATE_FILE):
@echo GitHub Org: $(README_TEMPLATE_REPO_ORG)
curl -o $@ -fsSL '$(README_TEMPLATE_REPO_URL)'

## Alias for readme/build
readme: readme/build
@exit 0
Expand All @@ -15,10 +40,10 @@ readme/deps: packages/install/gomplate
## Create basic minimalistic .README.md template file
readme/init:
@if [ -f $(README_YAML) ]; then \
echo "$(README_YAML) already exists!"; \
echo "$(README_YAML) already exists!"; \
else \
cp $(README_TEMPLATE_YAML) $(README_YAML) ; \
echo "$(README_YAML) created!"; \
cp $(README_TEMPLATE_YAML) $(README_YAML) ; \
echo "$(README_YAML) created!"; \
fi;

## Verify the `README.md` is up to date
Expand All @@ -28,7 +53,7 @@ readme/lint:
@rm -f $(README_LINT)

## Create README.md by building it from README.yaml
readme/build: readme/deps $(README_DEPS)
readme/build: readme/deps $(README_TEMPLATE_FILE) $(README_DEPS)
@gomplate --file $(README_TEMPLATE_FILE) --out $(README_FILE) --config $(BUILD_HARNESS_PATH)/configs/gomplate.yaml
@echo "Generated $(README_FILE) from $(README_TEMPLATE_FILE) using data from $(README_TEMPLATE_YAML)"

Expand Down
Loading
Loading