From d766f08338e292fef8b0a6d94543f7b4353f2a7f Mon Sep 17 00:00:00 2001 From: Deco Vander Date: Thu, 3 Jul 2025 22:53:53 -0400 Subject: [PATCH] Update deploy scripts to create a PR --- .github/workflows/deploy-scripts.yml | 58 +++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-scripts.yml b/.github/workflows/deploy-scripts.yml index 95ad2e7..86423e9 100644 --- a/.github/workflows/deploy-scripts.yml +++ b/.github/workflows/deploy-scripts.yml @@ -10,7 +10,8 @@ on: permissions: id-token: write - contents: read + contents: write + pull-requests: write jobs: deploy-scripts: @@ -59,9 +60,54 @@ jobs: echo "No README updates needed" else echo "README updated with new S3 URLs" - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add README.md - git commit -m "Update deployment URLs [skip ci]" - git push + + # Get current branch name + CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + echo "Current branch: $CURRENT_BRANCH" + + if [[ "$CURRENT_BRANCH" == "main" ]]; then + echo "On main branch - creating PR instead of direct commit" + + # Create a new branch for the update + BRANCH_NAME="update-readme-urls-$(date +%Y%m%d-%H%M%S)" + git checkout -b "$BRANCH_NAME" + + # Configure git and commit changes + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add README.md + git commit -m "Update deployment URLs + + - Updated S3 URLs in README.md + - Deploy script URL: https://${{ secrets.S3_BUCKET_NAME }}.s3.amazonaws.com/scripts/deploy.sh" + + # Push the new branch + git push origin "$BRANCH_NAME" + + # Create PR using GitHub CLI + gh pr create \ + --title "Update deployment URLs in README" \ + --body "🤖 **Automated update from deployment workflow** + + This PR updates the deployment URLs in README.md with the current S3 bucket URLs. + + **Changes:** + - Updated deploy script URL to: https://${{ secrets.S3_BUCKET_NAME }}.s3.amazonaws.com/scripts/deploy.sh + + **Generated by:** ${{ github.workflow }} workflow + **Commit:** ${{ github.sha }}" \ + --head "$BRANCH_NAME" \ + --base "main" + + echo "✅ PR created successfully!" + else + echo "Not on main branch - committing directly" + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add README.md + git commit -m "Update deployment URLs [skip ci]" + git push + fi fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}