Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
ci(GITHUB): reorder, upgrade action versions
Browse files Browse the repository at this point in the history
  • Loading branch information
niall-byrne committed Mar 5, 2023
1 parent c678219 commit 4cf0077
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 223 deletions.
245 changes: 134 additions & 111 deletions .github/workflows/self-test.yml

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
"author": "Niall Byrne",
"company": "Shared Vision Solutions",
"email": "[email protected]",
"_BRANCH_NAME_BASE": "master",
"_BRANCH_NAME_DEVELOPMENT": "dev",
"_GITHUB_CI_PYTHON_VERSIONS": ["3.9"],
"_GITHUB_ACTION_MARKDOWN_LINK_CHECK": "gaurav-nelson/[email protected]",
"_GITHUB_GITLEAKS_ACTION": "zricethezav/[email protected]",
"_GITHUB_PUSH_ACTION": "ad-m/[email protected]"
"_GITHUB_ACTION_CACHE": "actions/cache@v3",
"_GITHUB_ACTION_CHECKOUT": "actions/checkout@v3",
"_GITHUB_ACTION_GITLEAKS": "zricethezav/[email protected]",
"_GITHUB_ACTION_MARKDOWN_LINK_CHECK": "gaurav-nelson/github-action-markdown-link-check@v1",
"_GITHUB_ACTION_PYTHON": "actions/setup-python@v4",
"_GITHUB_ACTION_SCRIPT": "actions/github-script@v6",
"_GITHUB_ACTION_TRUFFLEHOG": "trufflesecurity/[email protected]",
"_GITHUB_ACTION_YAMLLINT": "ibiqlik/action-yamllint@v3"
}
38 changes: 30 additions & 8 deletions hooks/post_gen_project.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,55 @@
#!/bin/bash

# hooks/post_gen_project.sh
# Configures the templated profile for use.

# ANSIBLE_WORKBENCH_BRANCH_NAME_BASE: Optional alternate base branch name.
# ANSIBLE_WORKBENCH_BRANCH_NAME_DEVELOPMENT: Optional alternate development branch name.
# ANSIBLE_WORKBENCH_SKIP_POETRY: Optionally set to 1 to skip installing dependencies.

# cookiecutter only script.

ANSIBLE_WORKBENCH_BRANCH_NAME_BASE="${ANSIBLE_WORKBENCH_BRANCH_NAME_BASE-"{{ cookiecutter._BRANCH_NAME_BASE }}"}"
ANSIBLE_WORKBENCH_BRANCH_NAME_DEVELOPMENT="${ANSIBLE_WORKBENCH_BRANCH_NAME_DEVELOPMENT-"{{ cookiecutter._BRANCH_NAME_DEVELOPMENT }}"}"
ANSIBLE_WORKBENCH_TEMPLATE_URL="https://github.com/niall-byrne/ansible-workbench.git"

initialize_git() {

git init
git checkout -b master
git checkout -b "${ANSIBLE_WORKBENCH_BRANCH_NAME_BASE}"
git stage .
git commit -m "build(COOKIECUTTER): initial generation"
git symbolic-ref HEAD refs/heads/master
git symbolic-ref HEAD "refs/heads/${ANSIBLE_WORKBENCH_BRANCH_NAME_BASE}"
git tag v0.0.0
git checkout -b production
git checkout master
git checkout -b "${ANSIBLE_WORKBENCH_BRANCH_NAME_DEVELOPMENT}"
mkdir -p files templates

}

initialize_poetry() {
if [[ -z "$(poetry env list)" ]]; then

if [[ "${ANSIBLE_WORKBENCH_SKIP_POETRY}" != "1" ]]; then
poetry install
fi

}

update_template_values() {
# Compatible with Linux and BSD sed
sed -i.bak 's/ansible-workbench\//https:\/\/github.com\/niall-byrne\/ansible-workbench.git/' .cookiecutter/cookiecutter.json
rm .cookiecutter/cookiecutter.json.bak

if ! grep "${ANSIBLE_WORKBENCH_TEMPLATE_URL}" .cookiecutter/cookiecutter.json; then
# sed compatible with Linux and BSD
sed -i.bak 's,"_template": ".*","_template": "'"${ANSIBLE_WORKBENCH_TEMPLATE_URL}"'",g' .cookiecutter/cookiecutter.json
rm .cookiecutter/cookiecutter.json.bak
fi

}

main() {

update_template_values
initialize_git
initialize_poetry

}

main
23 changes: 23 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# scripts/test.sh
# Templates and builds the example role with default values for testing.

# Development only script.

set -eo pipefail

main() {

rm -rf ../flower-generator

pushd ..
echo -e "\n\n\n\n\n\n\n\n\n" | cookiecutter ansible-workbench
cd flower-generator
echo -e "\nExit from this shell when finished testing ..."
bash
popd

}

main "$@"
12 changes: 10 additions & 2 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

# Requires: https://pypi.org/project/cookiecutter-project-upgrader/

# 1: The path to the role folder you'll be upgrading.
# 2: The tag or branch of this repository you'll be using to perform the upgrade.

# Development only script.

set -eo pipefail

ANSIBLE_WORKBENCH_TEMPLATE_URL="https://github.com/niall-byrne/ansible-workbench.git"

error() {
echo "USAGE: ./update.sh [ROLE FOLDER] [TEMPLATE TAG or BRANCH]"
exit 127
Expand All @@ -21,15 +30,14 @@ main() {
-c .cookiecutter/cookiecutter.json \
-b "update-template" \
-u "$2" \
-f https://github.com/niall-byrne/ansible-workbench.git \
-f "${ANSIBLE_WORKBENCH_TEMPLATE_URL}" \
-e "defaults" \
-e "handlers" \
-e "meta" \
-e "molecule" \
-e "tasks" \
-e "tests" \
-e "vars" \
-e ".ansible-lint" \
-e ".gitignore" \
-e "pyproject.toml" \
-e "requirements.yml" \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
{
"httpHeaders": [
{
"urls": [
"https://github.com/",
"https://guides.github.com/",
"https://help.github.com/",
"https://docs.github.com/"
],
"headers": {
"Accept-Encoding": "zstd, br, gzip, deflate"
}
}
],
"ignorePatterns": [
{
"pattern": "^https://docs.github.com/"
"pattern": "^https://github.com/{{cookiecutter.github_handle}}/{{cookiecutter.project_slug}}/"
}
]
}
}
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.github/scripts/changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ main() {
echo "CHANGE_LOG_CONTENT<<EOF"
echo "${CHANGE_LOG_CONTENT}"
echo "EOF"
} >> "$GITHUB_ENV"
} >> "${GITHUB_ENV}"

rm package.json

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.github/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ main() {
echo "BRANCH_OR_TAG=${BRANCH_OR_TAG}"
echo "WEBHOOK_URL=${WEBHOOK_URL}"
echo "NOTIFICATION=${PROJECT_NAME} [<${WORKFLOW_URL}|${BRANCH_OR_TAG}>]"
} >> "$GITHUB_ENV"
} >> "${GITHUB_ENV}"

}

Expand Down
Loading

0 comments on commit 4cf0077

Please sign in to comment.