Skip to content

Commit

Permalink
Use external ght-render for ght-render-repo action (#9)
Browse files Browse the repository at this point in the history
* Use external ght-render action for PR and Push

* Update ISSUE_TEMPLATE.md.ght
  - Add header

* Remove ght-render dead-code
  • Loading branch information
sodre authored Jan 10, 2020
1 parent 93cff98 commit c7c9f2a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 136 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE.md.ght
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
### Environment Information
* {{ cookiecutter.project_name }} version:
* Python version:
* Operating System:
Expand Down
64 changes: 0 additions & 64 deletions .github/bin/ght-render.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ converged()
diff -q $1 $2 > /dev/null
}

tree_converged()
{
templ=$1;
rendered=$2;

# List all the types under the repo, ignoring the .git dir
find . -path ./.git -prune -o ${@:3} | grep -v '^\./\.git' | sort > ${templ}
render $templ $rendered

converged $templ $rendered
}

render_configuration()
{
set -e
Expand Down Expand Up @@ -70,58 +58,6 @@ render_configuration()
#git commit -m "ght: configuration rendered" $GHT_CONF
}

render_tree_structure()
{
for filter in "-type d" "-type f"; do
ght_temp=$(mktemp)
until tree_converged $ght_temp ${ght_temp}.rendered $filter ; do
paste -- $ght_temp $ght_temp.rendered |
while IFS=$'\t' read -r d1 d2; do
if [ $d1 != $d2 ]; then
git mv $d1 $d2 || true
fi
done
done
done
#git commit -m 'ght: template structure rendered'
}

render_tree_content()
{
find . -path ./.git -prune -o -type f |
grep -E -v './.git$|./.github' |
sort |
while IFS=$'\n' read -r in; do
out=$(mktemp)
echo "rendering ${in}"
render $in $out
cp -a ${out} ${in}
git add ${in}
done
#git commit -m 'ght: content rendered'
}

render_tree_ght_content()
{
find . -path ./.git -prune -o -type f -name '*.ght' |
grep -E -v './.git$' |
sort |
while IFS=$'\n' read -r in; do
out=${in/.ght/}
echo "rendering ${in}"
render $in $out
git rm -f ${in}
git add ${out}
done
#git commit -m 'ght: *.j2 content rendered and renamed'
}

remove_workflows()
{
git rm -f .github/workflows/ght-init.yml
git rm -f .github/workflows/ght-render-repo.yml
}

# This is so we can test things locally without screwing up the master branch
# tmp=$(basename $(mktemp -t ght-XXXX))
# git checkout -b $tmp
Expand Down
99 changes: 27 additions & 72 deletions .github/workflows/ght-render-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
pull_request:
branches:
- ght/master
push:
branches:
- ght/master

jobs:
ght-render-repo:
Expand All @@ -13,81 +16,33 @@ jobs:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Add ght-pypackage remote
run: |
git remote add ght-pypackage https://github.com/sodre/ght-pypackage.git
git fetch ght-pypackage
- name: Prepare tree for re-rendering
run: |
git rm -rf .
git checkout remotes/ght-pypackage/master -- .
git checkout ${{ github.head_ref }} -- .github/ght.yaml
- name: Set up Python 3.7
uses: actions/setup-python@v1
- name: Render the project template
uses: sodre/ght-render@master
with:
python-version: 3.7
- name: Install ght-render dependencies
run: |
python -m pip install --upgrade pip
pip install jinja2 jinja2-cli jinja2-time pyyaml
- run: |
.github/bin/ght-render.sh render-tree-structure
.github/bin/ght-render.sh render-tree-ght-content
.github/bin/ght-render.sh render-tree-content
#.github/bin/ght-render.sh remove-workflows
- uses: stefanzweifel/[email protected]
with:
commit_message: Apply automatic changes
branch: ${{ github.head_ref }}
template: sodre/ght-pypackage@master

- name: Push changes to ght/master
if: github.event_name == 'push'
run: git push --set-upstream origin HEAD:${{ github.ref }}
- name: Push changes to head_ref
if: github.event_name == 'pull_request'
run: git push --set-upstream origin ${{ github.head_ref}}

- name: Create pull-request against master
uses: octokit/[email protected]
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - run: |
# git config --global user.email "[email protected]"
# git config --global user.name "Auto-commit"
# git commit -m 'auto-commit'
# git push --set-upstream origin HEAD:${{ github.head_ref }} --force

- name: Create Pull Request
uses: peter-evans/create-pull-request@v1
if: false
with:
token: ${{ secrets.GITHUB_TOKEN }}
route: POST /repos/:repository/pulls
repository: ${{ github.repository }}
title: Merge ght/master into master
head: ght/master
base: master
branch: ght/render
branch-suffix: timestamp
commit-message: |
Render ght/master into master
This commit was obtained as follows:
1. Checkout the last merged rendering of ght/master
git checkout ${{ steps.last-render.outputs.treeish }}
2. Replace its contents with ght/master
git rm -rf .
git checkout origin/ght/master -- .
3. Load the configured ght.yaml from PR #${{ github.event.number }} file
git checkout ${{ github.sha }} -- .github/ght.yaml
4. Execute the rendering steps
.github/bin/ght-render.sh render_tree_structure
.github/bin/ght-render.sh render_tree_ght_content
.github/bin/ght-render.sh render_tree_content
.github/bin/ght-render.sh finish
5. Commit
git commit
Close #${{ github.event.number }}
title: Render ght/master into master
reviewers: ${{ github.actor }}
labels: ght
body: |
Please review the changes and fix any conflicts before merging.
If the configuration variables were incorrect, please close this PR and
use your ght-configure PR #${{ github.event.number }} to edit the values.
|
Modifications to ght/master were detected.
- [ ] Review the changes
- [ ] Fix the errors by committing back to ght/master
- [ ] Do **not** use Squash or Rebase
- [ ] Do **not** delete the ght/master branch

0 comments on commit c7c9f2a

Please sign in to comment.