Create empty GitHub repo and clone monorepo into it #19
Workflow file for this run
This file contains 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: 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 | |
path: 'cloned-repo' | |
- name: Push to a new branch | |
run: | | |
cd cloned-repo | |
git config user.name "DASK CI" | |
git config user.email "[email protected]" | |
git checkout -b clone-monorepo | |
git remote set-url origin https://github.com/kartverket/${{ env.REPO_NAME }}.git | |
git push -u origin clone-monorepo | |
- name: Create pull request | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ env.GITHUB_TOKEN }} | |
script: | | |
const repoName = ${{ env.REPO_NAME }}; | |
const owner = 'kartverket'; | |
const head = 'clone-monorepo'; | |
const base = 'main'; | |
const title = 'Clone monorepo reference setup into new repository'; | |
await github.rest.pulls.create({ | |
owner, | |
repo: repoName, | |
title, | |
head, | |
base, | |
}); |