-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alice Wasko <[email protected]>
- Loading branch information
Alice Wasko
committed
Jan 29, 2024
1 parent
d3c30eb
commit 6802dfc
Showing
10 changed files
with
84 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Generators | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
generate: | ||
name: Generate | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_API_KEY: ${{ secrets.GH_API_KEY }} | ||
steps: | ||
- name: Checkout local | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Git Config | ||
shell: bash | ||
run: | | ||
set -x | ||
git config --global user.email '${{ secrets.GH_AUTO_EMAIL }}' | ||
git config --global user.name '${{ secrets.GH_AUTO_USER }}' | ||
git config --global url.https://${GH_API_KEY}@github.com/.insteadOf https://github.com/ | ||
# Generate and then make sure no changes have occurred | ||
- name: Generate | ||
run: | | ||
make generate | ||
- name: Check porcelain | ||
run: | | ||
git add . | ||
if [[ -n "$(git status --porcelain)" ]]; then | ||
PAGER= git diff --cached | ||
exit 1 | ||
fi |
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,35 @@ | ||
GENERATORS_DIR := generators | ||
GENERATOR_METADATA_FILE := generator-config.yaml | ||
JSON_OUTPUT := generators.json | ||
|
||
# Setting SHELL to bash allows bash commands to be executed by recipes. | ||
# Options are set to exit when a recipe line exits non-zero or a piped command fails. | ||
SHELL = /usr/bin/env bash -o pipefail | ||
.SHELLFLAGS = -ec | ||
|
||
# Default `make` to run `make generate` | ||
.PHONY: all | ||
all: generate | ||
|
||
.PHONY: generate | ||
generate: | ||
@echo "{" > $(JSON_OUTPUT) | ||
@echo ' "generators": [' >> $(JSON_OUTPUT) | ||
@find $(GENERATORS_DIR) -type f -name $(GENERATOR_METADATA_FILE) | while read -r generator_config_file; do \ | ||
gen_dir="$$(dirname "$$generator_config_file")"; \ | ||
gen_name="$$(yq eval '.metadata.name' "$$generator_config_file")"; \ | ||
gen_description="$$(yq eval '.metadata.description' "$$generator_config_file")"; \ | ||
gen_version="$$(yq eval '.metadata.version' "$$generator_config_file")"; \ | ||
gen_languages="$$(yq eval '.metadata.languages' "$$generator_config_file")"; \ | ||
gen_hash="$$(find "$$gen_dir" -type f -exec md5sum {} + | awk '{print $$1}' | sort | md5sum | awk '{print $$1}')"; \ | ||
echo ' {' >> $(JSON_OUTPUT); \ | ||
echo ' "name": "'$$gen_name'",' >> $(JSON_OUTPUT); \ | ||
echo ' "description": "'$$gen_description'",' >> $(JSON_OUTPUT); \ | ||
echo ' "version": "'$$gen_version'",' >> $(JSON_OUTPUT); \ | ||
echo ' "languages": '$$gen_languages',' >> $(JSON_OUTPUT); \ | ||
echo ' "directory": "'$$gen_dir'",' >> $(JSON_OUTPUT); \ | ||
echo ' "hash": "'$$gen_hash'"' >> $(JSON_OUTPUT); \ | ||
echo ' },' >> $(JSON_OUTPUT); \ | ||
done | ||
@sed -i '$$s/,$$/]/' $(JSON_OUTPUT) | ||
@echo "}" >> $(JSON_OUTPUT) |
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 @@ | ||
{ | ||
"generators": [ | ||
{ | ||
"name": "Ambassador Labs Go Generator", | ||
"description": "Generates a new project for an API server writen in go", | ||
"version": "1.0.0", | ||
"languages": ["go"], | ||
"directory": "generators/go", | ||
"hash": "6fdd0aeefb61bbb9a9d70c2f007f18fb" | ||
}] | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.