Skip to content

Whitespace change to allow PR to run #25

Whitespace change to allow PR to run

Whitespace change to allow PR to run #25

name: Finalize Copybara Sync
on:
push:
branches:
- 'copybara/v*'
# Cancel any in-progress runs when a new commit is pushed to the same branch
# This ensures only the latest commit is processed when Copybara sends many commits quickly
concurrency:
group: copybara-sync-${{ github.ref }}
cancel-in-progress: true
jobs:
finalize:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Extract version from branch name
id: version
run: |
# Extract v1.2.3 from copybara/v1.2.3
VERSION=$(echo "$GITHUB_REF" | sed 's|refs/heads/copybara/||')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- uses: actions/checkout@v6
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Configure Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
- name: Run go mod tidy
run: go mod tidy
- name: Commit and push go mod tidy changes
run: |
if ! git diff --quiet go.mod go.sum; then
git add go.mod go.sum
git commit -m "Run go mod tidy"
git push origin ${{ github.ref_name }}
else
echo "No changes from go mod tidy"
fi
- name: Extract original commit author
id: author
run: |
# Get the GitHub username from the most recent non-bot commit
# Copybara preserves the original author via pass_thru
AUTHOR_EMAIL=$(git log -1 --format='%ae' --author='^(?!.*[email protected])' --perl-regexp 2>/dev/null || git log -1 --format='%ae')
AUTHOR_NAME=$(git log -1 --format='%an' --author='^(?!.*[email protected])' --perl-regexp 2>/dev/null || git log -1 --format='%an')
echo "email=$AUTHOR_EMAIL" >> $GITHUB_OUTPUT
echo "name=$AUTHOR_NAME" >> $GITHUB_OUTPUT
# Try to find GitHub username from email (works for users with public email)
# Format: [email protected] or regular email
if [[ "$AUTHOR_EMAIL" =~ ^([^@]+)@users\.noreply\.github\.com$ ]]; then
# Extract username from noreply email (handles 12345678+username format)
GITHUB_USER=$(echo "${BASH_REMATCH[1]}" | sed 's/^[0-9]*+//')
echo "github_user=$GITHUB_USER" >> $GITHUB_OUTPUT
else
echo "github_user=" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.version }}
AUTHOR_NAME: ${{ steps.author.outputs.name }}
AUTHOR_EMAIL: ${{ steps.author.outputs.email }}
GITHUB_USER: ${{ steps.author.outputs.github_user }}
run: |
# Build PR body
PR_BODY="## Copybara Sync - Release ${VERSION}
This PR was automatically created by Copybara, syncing changes from the [overmindtech/workspace](https://github.com/overmindtech/workspace) monorepo.
**Original author:** ${AUTHOR_NAME} (${AUTHOR_EMAIL})
### What happens when this PR is merged?
1. The \`tag-on-merge\` workflow will automatically create the \`${VERSION}\` tag on main
2. This tag will trigger the release workflow, which will:
- Run tests
- Build and publish release binaries via GoReleaser
- Upload packages to Cloudsmith
### Review Checklist
- [ ] Changes look correct and match the expected monorepo sync
- [ ] Tests pass (see CI checks below)
"
# Create the PR
PR_URL=$(gh pr create \
--base main \
--head "${{ github.ref_name }}" \
--title "Release ${VERSION}" \
--body "$PR_BODY")
echo "Created PR: $PR_URL"
# Try to assign reviewer - prefer original author, fall back to Engineering team
if [ -n "$GITHUB_USER" ]; then
echo "Requesting review from original author: $GITHUB_USER"
gh pr edit "$PR_URL" --add-reviewer "$GITHUB_USER" || true
fi
# Always add Engineering team as reviewer
echo "Requesting review from Engineering team"
gh pr edit "$PR_URL" --add-reviewer "overmindtech/Engineering" || true