Skip to content

Upgrade GitHub Actions versions #8

Upgrade GitHub Actions versions

Upgrade GitHub Actions versions #8

Workflow file for this run

name: Execute template to populate repository
on:
push:
workflow_dispatch:
permissions:
contents: write
jobs:
setup-repo:
if: ${{ github.repository != 'simonw/datasette-plugin-template-repository' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Install cookiecutter
run: pip install cookiecutter
- uses: actions/github-script@v7
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:simonw/datasette-plugin --no-input \
plugin_name=$(echo $INFO | jq -r '.repository.name | sub("datasette-"; "")') \
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)"
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@v5
with:
commit_message: "Initial library structure"
push_options: --force