Skip to content

πŸ”– Set canonincal dependencies + initial version and CHANGELOG #25

πŸ”– Set canonincal dependencies + initial version and CHANGELOG

πŸ”– Set canonincal dependencies + initial version and CHANGELOG #25

name: Update Repository URL
on:
pull_request_target:
jobs:
update-repo-url:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Update repository URL
env:
GITHUB_BASE_LOGIN: ${{ github.event.pull_request.base.repo.owner.login }}
GITHUB_BASE_REPO_NAME: ${{ github.event.pull_request.base.repo.name }}
GITHUB_REPO: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_REF: ${{ github.head_ref }}
run: |
TARGET_REPO_URL="https://github.com/${GITHUB_BASE_LOGIN}/${GITHUB_BASE_REPO_NAME}"
# Update the repository field in pyproject.toml
if grep -q '^repository = ' pyproject.toml; then
echo "Updating repository URL in pyproject.toml..."
sed -i "s|^repository = \".*\"|repository = \"$TARGET_REPO_URL\"|" pyproject.toml
else
echo "Adding repository URL to pyproject.toml..."
echo "repository = \"$TARGET_REPO_URL\"" >> pyproject.toml
fi
# Commit and push changes
git config --local user.email "[email protected]"
git config --local user.name "🐈 Theodore"
git remote set-url --push origin "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPO}"
git add pyproject.toml
git commit -m ":twisted_rightwards_arrows: Update repository URL to PR target." || exit 0
git push origin HEAD:"${HEAD_REF}"