-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(redo-typo-pr): added a new reusable action #121
Open
sysrex
wants to merge
2
commits into
main
Choose a base branch
from
sysrex/reusable_typos_block
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+80
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,45 @@ | ||
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.CELESTIA_BOT_GITHUB_TOKEN }} | ||
|
||
- name: Authenticate with GitHub CLI | ||
run: | | ||
echo "${{ secrets.CELESTIA_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 celestia-bot | ||
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 }} | ||
|
||
Check failure on line 45 in .github/workflows/reusable_redo_typo_pr.yml GitHub Actions / yamllint
|
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,35 @@ | ||
#!/bin/bash | ||
|
||
set -eux | ||
|
||
# Configuration | ||
ORIGINAL_PR_NUMBER=$1 | ||
REPO='celestiaorg/*' | ||
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 master | ||
echo "Squashing PR branch onto master" | ||
git checkout master | ||
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="celestia-bot <[email protected]>" -m "chore: redo typo PR" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, maybe env var if not |
||
|
||
# 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 master --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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not blocker -
I'd add these two values to the secrets, to don't publish them