-
Notifications
You must be signed in to change notification settings - Fork 2
70 lines (63 loc) · 2.24 KB
/
create-and-clone-repo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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 add .
git commit -m "Cloning monorepo from kartverket/dask-monorepo-reference-setup"
git remote add 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,
});