-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from AztecProtocol/mt/support-redo-typo-prs
copy workflows from aztec packages
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Redo Typo PR | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
pr_number: | ||
description: "The PR number to redo" | ||
required: true | ||
type: string | ||
|
||
pull_request_target: | ||
types: [labeled] | ||
branches: | ||
- master | ||
paths-ignore: | ||
- "**/README.md" | ||
|
||
jobs: | ||
redo-typo-pr: | ||
if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'redo-typo-pr') | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} | ||
|
||
- name: Authenticate with GitHub CLI | ||
run: | | ||
echo "${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}" | gh auth login --with-token | ||
- name: Set git configure for commits | ||
run: | | ||
# Identify ourselves, needed to commit | ||
git config --global user.name AztecBot | ||
git config --global user.email [email protected] | ||
- name: Determine PR number | ||
id: determine-pr-number | ||
run: echo "PR_NUMBER=${{ github.event.inputs.pr_number || github.event.pull_request.number }}" >> $GITHUB_ENV | ||
|
||
- name: Run repo-typo-pr script | ||
run: ./scripts/redo-typo-pr ${{ env.PR_NUMBER }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
set -eux | ||
|
||
# Configuration | ||
ORIGINAL_PR_NUMBER=$1 | ||
REPO='AztecProtocol/engineering-designs' | ||
NEW_BRANCH="chore/typo-redo-$ORIGINAL_PR_NUMBER" | ||
AUTHOR=`gh pr view $ORIGINAL_PR_NUMBER --json author --jq '.author.login'` | ||
|
||
# Step 1: Checkout the PR locally | ||
echo "Checking out PR #$ORIGINAL_PR_NUMBER" | ||
gh pr checkout $ORIGINAL_PR_NUMBER --branch "typo-pr-branch" | ||
|
||
# Step 2: Create squash commit on main | ||
echo "Squashing PR branch onto main" | ||
git checkout main | ||
git merge "typo-pr-branch" --squash | ||
|
||
# Step 3: Commit squash commit to new branch | ||
echo "Creating new local branch $NEW_BRANCH" | ||
git checkout -b $NEW_BRANCH | ||
git commit -a --author="AztecBot <[email protected]>" -m "chore: redo typo PR" | ||
|
||
# Step 4: Push the new branch to GitHub | ||
echo "Pushing new branch $NEW_BRANCH to GitHub" | ||
git push origin $NEW_BRANCH | ||
|
||
# Step 5: create a new pull request | ||
echo "Creating a new pull request for $NEW_BRANCH" | ||
gh pr create --base main --head $NEW_BRANCH --title "chore: redo typo PR by $AUTHOR" --body "Thanks $AUTHOR for https://github.com/$REPO/pull/$ORIGINAL_PR_NUMBER. Our policy is to redo typo changes to dissuade metric farming. This is an automated script." | ||
|
||
# Step 6: Close the original PR | ||
echo "Closing original PR #$ORIGINAL_PR_NUMBER" | ||
gh pr close $ORIGINAL_PR_NUMBER | ||
|
||
echo "Script completed." |