Skip to content

Commit

Permalink
Merge pull request #5 from climate-resource/fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisjared authored Oct 16, 2024
2 parents 3f787a4 + 7c9b83d commit 2280f6b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog/5.improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Provide a saner default for the project url
5 changes: 3 additions & 2 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ dataset_description:
project_url:
type: str
help: What is the URL for your project?
placeholder: "https://github.com/climate-resource/project-name"
default: |-
https://github.com/climate-resource/bookshelf-{{ dataset_name }}
validator: >-
{% if not (project_url | regex_search('^https:\/\/\S*(github.com)\/\S*$')) %}
That doesn't look like a valid URL, please check. Only GitHub URLs are supported.
Expand All @@ -47,7 +48,7 @@ _envops:
lstrip_blocks: true

_tasks:
- '[ ! -d ".git" ] && git init'
- '[ ! -d ".git" ] && git init || exit 0'
# This should create a lockfile
- 'make virtual-environment && git add .'

Expand Down
49 changes: 49 additions & 0 deletions scripts/create-github-project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Create a new GH repository for a given project
# Usage: bash create-github-project.sh my-project-name

ORGANISATION="climate-resource"
REPO_NAME=$1

CR_ORG_ID=$(gh api graphql -F owner=$ORGANISATION -f query='
query($owner: String!) {
organization(login: $owner) {
id
}
}
' | jq -r '.data.organization.id'
)


RESP=$(gh api graphql -F ownerId=$CR_ORG_ID -F name=$REPO_NAME -f query='
mutation ($ownerId: ID!, $name: String!) {
createRepository(
input: {
ownerId: $ownerId,
name: $name,
visibility: PUBLIC
}
)
{
repository {
id,
databaseId,
name,
url,
sshUrl
}
}
}
'
)
echo $RESP

REPO_ID=$(echo $RESP | jq -r '.data.createRepository.repository.databaseId')

# Set visibility to the access token
# This only works for public repos
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/$ORGANISATION/actions/secrets/PERSONAL_ACCESS_TOKEN/repositories/$REPO_ID
2 changes: 1 addition & 1 deletion template/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
- name: Run tests
run: |
[[ ! -d "tests" ]] && exit 0
uv run pytest src tests -r a -v --doctest-modules
uv run pytest tests -r a -v
2 changes: 1 addition & 1 deletion tests/regression/ctt/defaults/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
- name: Run tests
run: |
[[ ! -d "tests" ]] && exit 0
uv run pytest src tests -r a -v --doctest-modules
uv run pytest tests -r a -v

0 comments on commit 2280f6b

Please sign in to comment.