-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
774 additions
and
624 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,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
# function to copy for all subdirs on the first level the README.md file to the target dir and rename the file to name of the dir | ||
# also inject a line on the top of the file <!-- This file is generated. Do not edit! --> | ||
# and exclude the base dir as well the exclsuion list | ||
# | ||
# $1 source dir | ||
# $2 target directory | ||
# $3 list of directories to exclude | ||
function copy_readme { | ||
mkdir -p $2 | ||
for dir in $(find $1 -mindepth 1 -maxdepth 1 -type d); do | ||
# ignore dirs in in the exclusion list (comma seprated listed) | ||
if [[ "$3" == *$(basename $dir)* ]]; then | ||
echo IGNORE $dir | ||
continue | ||
fi | ||
|
||
# Check if the subdirectory exists in Git | ||
if git rev-parse --is-inside-work-tree &>/dev/null && git ls-files --error-unmatch "$dir" &>/dev/null; then | ||
echo "Copying README.md from ${dir} to $2" | ||
pushd "$dir" >/dev/null | ||
cp README.md ../../$2/$(basename $dir).md | ||
|
||
# inject the folloing comment on the top <!-- This file is generated. Do not edit! PLEASE edit https://github.com/philips-labs/terraform-aws-github-runner/blob/main/$dir/README.md --> | ||
sed -i "1s;^;<!-- This file is generated. Do not edit! PLEASE edit https://github.com/philips-labs/terraform-aws-github-runner/blob/main/$dir/README.md -->\n;" ../../$2/$(basename $dir).md | ||
popd >/dev/null | ||
fi | ||
done | ||
} | ||
|
||
|
||
# copy for all subdirs in examples the READM.md file to the docs directory and replace the filename by the name of the dir with extension md | ||
|
||
copy_readme examples docs/generated/examples "examples/base" | ||
copy_readme modules docs/generated/modules/internal "multi-runner,ami-housekeeper,download-lambda,setup-iam-permissions," | ||
copy_readme modules docs/generated/modules/public "webhook,runner-binaries-syncer,runners,ssm,webhook-github-app" | ||
|
||
|
||
# for dir in $(find examples -mindepth 1 -maxdepth 1 -type d); do | ||
# # ignore dirs that are contained in $1 | ||
# if [[ "$1" == *$(basename $dir)* ]]; then | ||
# echo MATCH | ||
# continue | ||
# fi | ||
# echo no match $dir | ||
# done | ||
|
||
|
||
# for dir in $(find examples -mindepth 1 -maxdepth 2 -type d); do | ||
# # ignore dir base | ||
# if [[ "$dir" == "examples/base" ]]; then | ||
# continue | ||
# fi | ||
# # Check if the subdirectory exists in Git | ||
# if git rev-parse --is-inside-work-tree &>/dev/null && git ls-files --error-unmatch "$dir" &>/dev/null; then | ||
# echo "Copying README.md from ${dir} to docs" | ||
# pushd "$dir" >/dev/null | ||
# cp README.md ../../docs/examples/$(basename $dir).md | ||
|
||
# # inject the folloing comment on the top <!-- This file is generated. Do not edit! --> | ||
# sed -i '1s;^;<!-- This file is generated. Do not edit! -->\n;' ../../docs/examples/$(basename $dir).md | ||
# popd >/dev/null | ||
# fi | ||
# done | ||
|
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,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script will run terraform init in all subdirectories of the examples directory | ||
# required to run tflint via pre-commit | ||
|
||
# only run the script if a uniique pid file exits if not creat it or --force flag is passed | ||
pid="/tmp/philips-labs-terraform-aws-github-runner.pid" | ||
if [ "$1" == "--force" ]; then | ||
rm -f /tmp/philips-labs-terraform-aws-github-runner.pid | ||
fi | ||
|
||
if [ ! -f $pid ]; then | ||
echo $$ > $pid | ||
else | ||
echo "Init all terraform directories will be skipped. To run the script remove the file $pid or run with --force" | ||
exit 0 | ||
fi | ||
|
||
# Change to the examples directory | ||
example_dirs=$(find examples -mindepth 1 -maxdepth 2 -type d | grep -v "templates") | ||
module_dirs=$(find modules -mindepth 1 -maxdepth 2 -type d | grep -v "templates") | ||
|
||
# merge example_dirs and module_dirs in terraform_dirs | ||
terraform_dirs=$(echo $example_dirs $module_dirs "modules/runners/pool" | tr " " "\n" | sort -u | tr "\n" " ") | ||
|
||
for dir in $terraform_dirs; do | ||
# Check if the subdirectory exists in Git | ||
if git rev-parse --is-inside-work-tree &>/dev/null && git ls-files --error-unmatch "$dir" &>/dev/null; then | ||
echo "Running terraform init in ${dir} - supressing output" | ||
pushd "$dir" >/dev/null | ||
terraform init -lockfile=readonly -backend=false &>/dev/null || true | ||
popd >/dev/null | ||
fi | ||
done |
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 |
---|---|---|
|
@@ -32,9 +32,32 @@ jobs: | |
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # ratchet:peter-evans/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: "Update Terraform docs" | ||
commit-message: "docs: auto update terraform docs" | ||
title: "docs: Update Terraform docs" | ||
branch: update-docs | ||
branch-suffix: random | ||
base: ${{ github.event.pull_request.base.ref }} | ||
delete-branch: true | ||
|
||
deploy-pages: | ||
needs: [docs] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4 | ||
- name: Configure Git Credentials | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.x | ||
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | ||
- uses: actions/cache@v3 | ||
with: | ||
key: mkdocs-material-${{ env.cache_id }} | ||
path: .cache | ||
restore-keys: | | ||
mkdocs-material- | ||
- run: pip install mkdocs-material | ||
- run: pip install mkdocs-material-extensions | ||
- run: mkdocs gh-deploy --force -c -b npalm/test |
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 |
---|---|---|
|
@@ -22,3 +22,4 @@ secrets.auto.tfvars | |
**/coverage/* | ||
|
||
node_modules/ | ||
site/ |
Oops, something went wrong.