Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GuusdeWit authored Sep 27, 2023
0 parents commit e36bb82
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Generate plugin

on:
push:
workflow_dispatch:

permissions:
contents: write

jobs:
setup-repo:
if: ${{ github.repository != 'GuusdeWit/ret-plugin-template-repository' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Install cookiecutter
run: pip3 install cookiecutter

- uses: actions/github-script@v4
id: fetch-repo-and-user-details
with:
script: |
const query = `query($owner:String!, $name:String!) {
repository(owner:$owner, name:$name) {
name
description
owner {
login
... on User {
name
}
... on Organization {
name
}
}
}
}`;
const variables = {
owner: context.repo.owner,
name: context.repo.repo
}
const result = await github.graphql(query, variables)
console.log(result)
return result
- name: Rebuild contents using cookiecutter
env:
INFO: ${{ steps.fetch-repo-and-user-details.outputs.result }}
run: |
export REPO_NAME=$(echo $INFO | jq -r '.repository.name')
# Run cookiecutter
pushd /tmp
cookiecutter gh:GuusdeWit/cookiecutter-ret-plugin-kotlin-maven --no-input \
pluginName=$(echo $INFO | jq -r '.repository.name | sub("ret-"; "")') \
description="$(echo $INFO | jq -r .repository.description)"
popd
# Move generated content to root directory of repo
mv /tmp/$REPO_NAME/* .
# And .gitignore too:
mv /tmp/$REPO_NAME/.gitignore .
# Delete the setup.yml workflow, it has served its purpose
rm .github/workflows/setup.yml
- name: Force push new repo contents
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Initial plugin structure"
push_options: --force
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Template repository for creating new RET plugins

This GitHub template can be used to easily scaffold a new [RET](https://github.com/rabobank/ret-engineering-tools) plugin.
Simply click on "Use this template" and fill in a repository name and description.

**Important:** your repository name must be prefixed by `ret-`, e.g. `ret-relax` is a valid repository name.

After clicking the create button, you will have a new repository that looks very similar to this one.
If you are reading this in your own newly created repo: congrats! Your scaffolded plugin will appear in a minute or so (after a refresh). In the meantime, enjoy this waiting music:

![](https://github.com/GuusdeWit/ret-plugin-template-repository/blob/main/waiting.gif)

## Credits

This template setup inspired by a similar [template repository for datasette plugins](https://github.com/simonw/datasette-plugin-template-repository), created by [Simon Willison](https://github.com/simonw)
Binary file added waiting.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e36bb82

Please sign in to comment.