-
Notifications
You must be signed in to change notification settings - Fork 2
96 lines (87 loc) · 3.27 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Create empty GitHub repo and clone monorepo into it
on:
workflow_dispatch:
inputs:
team_name:
description: "The team name"
required: true
type: string
project_name:
description: "The project name used to create the data-ingestor repo"
required: true
type: string
service_account:
description: "The GCP service account connected to the identity pool that will be used by Terraform for authentication to GCP."
required: true
type: string
auth_project_number:
description: "The GCP Project Number used for authentication. A 12-digit number used as a unique identifier for the project. Used to find workload identity pool."
required: true
type: string
script_params:
description: "Parameters to use in the script"
required: false
debug_mode:
description: "If the workflow should actually create resources or just run through without doing so."
required: false
type: boolean
default: false
env:
GITHUB_TOKEN: ${{ secrets.DASK_ONBOARDING_PAT }}
DEBUG_MODE: ${{ inputs.debug_mode }}
TEAM_NAME: ${{ inputs.team_name }} # Lowercase-name-for-team
REPO_NAME: ${{ inputs.project_name }}-data-ingestor
AUTH_PROJECT_NUMBER: ${{ inputs.auth_project_number }}
SERVICE_ACCOUNT: ${{ inputs.service_account }}
jobs:
create_and_clone_repo:
runs-on: ubuntu-latest
steps:
- name: Create empty repo
if: env.DEBUG_MODE == 'false'
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: repoName,
description: 'This is your first repository',
visibility: 'internal',
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
if: env.DEBUG_MODE == 'false'
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
send_success_message_to_pubsub:
needs: create_and_clone_repo
uses: ./.github/workflows/publish-message-pubsub.yml
permissions:
id-token: write
with:
auth_project_number: ${{ inputs.auth_project_number }}
service_account: ${{ inputs.service_account }}
team_name: ${{ inputs.team_name }}
params: ${{ inputs.script_params }}
step_id: setup-ingestor