Skip to content

Create New Project

Create New Project #19

name: Create New Project
on:
workflow_dispatch:
inputs:
projectName:
description: The name of the new project to create.
required: true
type: string
templateRepoOrg:
description: The organization of the template repository to clone from.
required: true
type: string
default: noahburrell0
templateRepoName:
description: The name of the template repository to clone from.
required: true
type: string
default: project-template
jobs:
clone-template-repo:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Create repo from template
run: gh repo create argocd-project-${{ inputs.projectName }} --template ${{ inputs.templateRepoOrg }}/${{ inputs.templateRepoName }} --clone --public
- name: Find/replace project name
run: |
sed -i "s/REPLACE_ME_NAME/guestbook-${{ inputs.projectName }}/g" argocd-project-${{ inputs.projectName }}/apps/guestbook.yaml
sed -i "s/REPLACE_ME_PROJECT/${{ inputs.projectName }}/g" argocd-project-${{ inputs.projectName }}/apps/guestbook.yaml
sed -i "s/REPLACE_ME_REPO/https:\/\/github.com\/${{ inputs.templateRepoOrg }}\/argocd-project-${{ inputs.projectName }}.git/g" argocd-project-${{ inputs.projectName }}/apps/guestbook.yaml
- name: Setup git and push changes
run: |
cd argocd-project-${{ inputs.projectName }}
/usr/bin/git config --global url."https://${GH_TOKEN}:[email protected]/".insteadOf "https://github.com/"
/usr/bin/git config --global user.name "Akuity Bot"
/usr/bin/git config --global user.email "[email protected]"
/usr/bin/git add -A
/usr/bin/git commit -m "Update project name"
/usr/bin/git push -u origin main
add-project:
runs-on: ubuntu-latest
needs: clone-template-repo
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create project and app-of-apps files
run: |
cp project-quickstart/templates/application.yaml project-quickstart/argocd/apps/app-of-apps-${{ inputs.projectName }}.yaml
cp project-quickstart/templates/project.yaml project-quickstart/argocd/projects/${{ inputs.projectName }}.yaml
sed -i "s/REPLACE_ME_NAME/app-of-apps-${{ inputs.projectName }}/g" project-quickstart/argocd/apps/app-of-apps-${{ inputs.projectName }}.yaml
sed -i "s/REPLACE_ME_REPO/https:\/\/github.com\/${{ inputs.templateRepoOrg }}\/argocd-project-${{ inputs.projectName }}.git/g" project-quickstart/argocd/apps/app-of-apps-${{ inputs.projectName }}.yaml
sed -i "s/REPLACE_ME_PROJECT/${{ inputs.projectName }}/g" project-quickstart/argocd/projects/${{ inputs.projectName }}.yaml
- name: Setup git and push changes
run: |
/usr/bin/git config --global user.name "Akuity Bot"
/usr/bin/git config --global user.email "[email protected]"
/usr/bin/git add -A
/usr/bin/git commit -m "Add ${{ inputs.projectName }} project"
/usr/bin/git push -u origin main