Skip to content

Create empty GitHub repo and clone monorepo into it #52

Create empty GitHub repo and clone monorepo into it

Create empty GitHub repo and clone monorepo into it #52

name: Create empty GitHub repo and clone monorepo into it
on:
workflow_dispatch:
inputs:
team_name:
description: "The team 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
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.team_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:
runs-on: ubuntu-latest
needs: create_and_clone_repo
permissions:
id-token: write
steps:
- name: Send success message to Pub/Sub
uses: ./.github/workflows/publish-message-pubsub.yml
with:
auth_project_number: ${{ env.AUTH_PROJECT_NUMBER }}
service_account: ${{ env.SERVICE_ACCOUNT }}
team_name: ${{ env.TEAM_NAME }}
step_id: setup-ingestor