Skip to content

Duplicate Repository #4

Duplicate Repository

Duplicate Repository #4

Workflow file for this run

name: Duplicate Repository
on:
workflow_dispatch:
inputs:
destination_user:
description: 'Destination user or organization'
required: true
default: 'eidolon-ai'
destination_repo:
description: 'Name of the new repository'
required: true
visibility:
description: 'Repository visibility (public or private)'
required: true
default: 'public'
type: choice
options:
- public
- private
jobs:
duplicate_repository:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
- name: Create new repository
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
gh repo create ${{ github.event.inputs.destination_user }}/${{ github.event.inputs.destination_repo }} --${{ github.event.inputs.visibility }}
- name: Push main branch to new repository
run: |
git push https://github.com/${{ github.event.inputs.destination_user }}/${{ github.event.inputs.destination_repo }}.git main
- name: Checkout new repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.destination_user }}/${{ github.event.inputs.destination_repo }}
token: ${{ secrets.GH_PAT }}
- name: Update README.md
run: |
OLD_ORG=$(echo ${{ github.event.inputs.source_org_repo }} | cut -d '/' -f 1)
OLD_REPO=$(echo ${{ github.event.inputs.source_org_repo }} | cut -d '/' -f 2)
sed -i "s|$OLD_ORG|${{ github.event.inputs.destination_user }}|g" README.md
sed -i "s|$OLD_REPO|${{ github.event.inputs.destination_repo }}|g" README.md
make poetry.lock
- name: Commit and push changes
run: |
git config --global user.email "[email protected]"
git config --global user.name "autodupe"
git add README.md
git commit -m "Update README.md with new organization and repository name"
git push