Bir repository yaratırız ve .github/workflows/create-spring-boot-repository.yaml dosyasını yaratırız. Dosya şöyle. Dosyanın çalışması için bir personal access token yaratılır ve secret olarak kaydedilir
name: Create Spring Boot Repositoryon:workflow_dispatch:inputs:name:description: 'Repository Name'required: truedescription:description: 'Repository Description'required: trueprivate:description: 'Private Repository'required: truedefault: 'false'groupId:description: 'Maven Group ID'required: trueartifactId:description: 'Maven Artifact ID'required: truespringBootVersion:description: 'Spring Boot Version'required: truedefault: '3.0.0'mainClassName:description: 'Main Class Name'required: truedefault: 'Application'userName:description: 'User Name'required: trueuserEmail:description: 'User Email'required: truejobs:create-spring-boot-repository:runs-on: ubuntu-lateststeps:- name: Step 1 - Checkout codeuses: actions/checkout@v3- name: Step 2 - Generate Spring Boot Project with Maven Wrapperrun: |curl https://start.spring.io/starter.zip -o project.zip \-d type=maven-project \-d bootVersion=${{ github.event.inputs.springBootVersion }} \-d groupId=${{ github.event.inputs.groupId }} \-d artifactId=${{ github.event.inputs.artifactId }} \-d name=${{ github.event.inputs.mainClassName }}unzip project.zip -d spring-boot-projectcd spring-boot-projectmvn wrapper:wrapper- name: Step 3 - Create new GitHub repositoryrun: |curl -X POST -H "Authorization: token ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}" \-d '{"name": "${{ github.event.inputs.name }}","description": "${{ github.event.inputs.description }}","private": ${{ github.event.inputs.private }}}' \https://api.github.com/user/repos- name: Step 4 - Push to new repositoryrun: |cd spring-boot-projectecho "# ${{ github.event.inputs.name }}" >> README.mdgit config --global user.email "${{ github.event.inputs.userEmail }}"git config --global user.name "${{ github.event.inputs.userName }}"git initgit add .git add README.mdgit commit -m "first commit"git branch -M maingit remote add origin git@github.com:${{ github.actor }}/${{ github.event.inputs.name }}.gitgit remote set-url origin https://x-access-token:${{ env.GH_PERSONAL_ACCESS_TOKEN }}@github.com/${{ github.actor }}/${{ github.event.inputs.name }}git push -u origin main # Push to 'main' branchenv:GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
Hiç yorum yok:
Yorum Gönder