chore: drop .idea/ from .gitignore (#3) #9
This file contains hidden or 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
| name: Execute template to populate repository | |
| on: | |
| push: | |
| workflow_dispatch: | |
| jobs: | |
| setup-repo: | |
| if: ${{ github.repository != 'xsh-lib/template' }} | |
| 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 | |
| cookiecutter . --output-dir /tmp --no-input \ | |
| lib_name=$REPO_NAME \ | |
| description="$(echo $INFO | jq -r .repository.description)" \ | |
| github_username="$(echo $INFO | jq -r .repository.owner.login)" \ | |
| author_name="$(echo $INFO | jq -r .repository.owner.name)" | |
| # Delete the template files, they have served their purpose | |
| rm .github/workflows/setup.yml | |
| rm cookiecutter.json | |
| rm -rf '{{cookiecutter.lib_name}}' | |
| rm -rf assets | |
| # Move generated content to root directory of repo | |
| mv /tmp/$REPO_NAME/* . | |
| # And .gitignore too: | |
| mv /tmp/$REPO_NAME/.gitignore . | |
| # And the generated CI workflow (hidden .github dir isn't matched by | |
| # the glob above); the template's own .github/workflows/ already | |
| # exists here (setup.yml was just removed from it). | |
| mv /tmp/$REPO_NAME/.github/workflows/test.yml .github/workflows/ | |
| - name: Force push new repo contents | |
| uses: stefanzweifel/git-auto-commit-action@v4 | |
| with: | |
| commit_message: "Initial library structure" | |
| push_options: --force |