Skip to content

Create empty GitHub repo and clone monorepo into it #34

Create empty GitHub repo and clone monorepo into it

Create empty GitHub repo and clone monorepo into it #34

name: Create empty GitHub repo and clone monorepo into it
on:
workflow_dispatch:
inputs:
repo_name:
description: "The name of the repository to create"
required: true
type: string
env:
GITHUB_TOKEN: ${{ secrets.DASK_ONBOARDING_PAT }}
REPO_NAME: ${{ inputs.repo_name }}
jobs:
create_and_clone_repo:
runs-on: ubuntu-latest
steps:
- name: Create empty repo
uses: actions/github-script@v7
with:
github-token: ${{ env.GITHUB_TOKEN }}
script: |
const repoName = '${{ env.REPO_NAME }}';
const response = await github.request('POST /orgs/{org}/repos', {
org: 'kartverket',
name: '${{ env.REPO_NAME }}',
description: 'This is your first repository',
visibility: 'public',
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
});
console.log(`Response for creating repo ${repoName}:`, response);
- name: Checkout the reference repository
uses: actions/checkout@v4
with:
repository: kartverket/dask-monorepo-reference-setup
ref: main
token: ${{ env.GITHUB_TOKEN }}
- name: Push to a new branch
run: |
git config --global user.name "DASK CI"
git config --global user.email "[email protected]"
rm -rf .git
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://x-access-token:${{env.GITHUB_TOKEN}}@github.com/kartverket/${{ env.REPO_NAME }}.git
echo "git status: $(git status)"
echo "git push"
git push -u origin main