Skip to content

Commit

Permalink
Reset instance on push to main (#71)
Browse files Browse the repository at this point in the history
* Pin cookiecutter version for GitHub workflow

* Add workflow to reset instance

* Fix typo in repository name
  • Loading branch information
oncleben31 committed Nov 18, 2020
1 parent 17c398c commit 4b8a77a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pip==20.2.4
pre-commit==2.8.2
nox==2020.8.22
cookiecutter==1.7.2
65 changes: 65 additions & 0 deletions .github/workflows/reset-instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Reset instance
on:
push:
branches:
- main
jobs:
instance:
runs-on: ubuntu-latest
steps:
- name: Check out cookiecutter-homeassistant-custom-component
uses: actions/checkout@v2.3.4
with:
path: cookiecutter-homeassistant-custom-component
- name: Check out cookiecutter-homeassistant-custom-component-instance
uses: actions/checkout@v2.3.4
with:
repository: "oncleben31/cookiecutter-homeassistant-custom-component-instance"
path: cookiecutter-homeassistant-custom-component-instance
token: ${{ secrets.X_GITHUB_TOKEN }}
- name: Set up Python 3.9
uses: actions/setup-python@v2.1.4
with:
python-version: "3.9"
- name: Install cookiecutter
working-directory: cookiecutter-homeassistant-custom-component
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=.github/workflows/constraints.txt cookiecutter
- name: Remove working tree
run: |
mv cookiecutter-homeassistant-custom-component-instance/.git tmp.git
rm -rf cookiecutter-homeassistant-custom-component-instance
mkdir cookiecutter-homeassistant-custom-component-instance
mv tmp.git cookiecutter-homeassistant-custom-component-instance/.git
- name: Invoke cookiecutter
run: >-
cookiecutter
https://github.com/${GITHUB_REPOSITORY}
--overwrite-if-exists
--no-input
friendly_name="Cookiecutter Home Assistant Custom Component Instance"
domain_name=cookiecutter_homeassistant_custom_component_instance
project_name=cookiecutter-homeassistant-custom-component-instance
- name: Create commit
run: |
cd cookiecutter-homeassistant-custom-component
author="$(git show --no-patch --format='%an <%ae>')"
date="$(git show --no-patch --format=%ad)"
message="$(git show --no-patch --format=%B | sed 's/ *(#[0-9]\+)//g')
Original-Commit: ${GITHUB_REPOSITORY}@${GITHUB_SHA::7}"
cd ../cookiecutter-homeassistant-custom-component-instance
git config --local user.name "GitHub Action"
git config --local user.email "action@github.com"
git add .
git commit --allow-empty --author="$author" --date="$date" --message="$message"
- name: Push to instance
run: >-
git
-C cookiecutter-homeassistant-custom-component-instance
push
https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/oncleben31/cookiecutter-homeassistant-custom-component-instance.git
HEAD:main

0 comments on commit 4b8a77a

Please sign in to comment.