Skip to content

Commit 52b62ae

Browse files
committed
sweet
1 parent 788d4c4 commit 52b62ae

4 files changed

Lines changed: 18 additions & 87 deletions

File tree

.github/workflows/softfix.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
name: Softfix workflow
21
on:
32
issue_comment:
43
types: [created]
4+
name: Automatic Rebase
55
jobs:
6-
softfix:
7-
name: Softfix action
6+
rebase:
7+
name: Rebase
88
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/softfix')
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
12-
- uses: ./
11+
- uses: actions/checkout@v1
12+
- name: Softfix
13+
uses: ./action.yml
1314
env:
14-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Softfix"
2+
description: "Fix up a pr from a beginner while reviewing"
3+
author: "dkvldev@gmail.com"
4+
5+
runs:
6+
using: "docker"
7+
image: "Dockerfile"
8+
9+
branding:
10+
icon: "git-commit"
11+
color: "green"

entrypoint.sh

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,84 +4,3 @@ echo "hi"
44

55
set -e
66

7-
cat $GITHUB_EVENT_PATH
8-
9-
PR_NUMBER=$(jq -r ".issue.number" "$GITHUB_EVENT_PATH")
10-
COMMENT_BODY=$(jq -r ".comment.body" "$GITHUB_EVENT_PATH")
11-
12-
echo $COMMENT_BODY
13-
14-
echo "Softfixing #$PR_NUMBER in $GITHUB_REPOSITORY"
15-
16-
if [[ -z "$GITHUB_TOKEN" ]]; then
17-
echo "Set a github token"
18-
exit 1
19-
fi
20-
21-
URI="https://api.github.com"
22-
ACCEPT_HEADER="Accept: application/vnd.github.v3+json"
23-
AUTH_HEADER="Authorization: token $GITHUB_TOKEN"
24-
25-
pr_response=$(curl -s -H "${AUTH_HEADER}" -H "${API_HEADER}" \
26-
"${URI}/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER")
27-
28-
BASE_REPO=$(echo "$pr_response" | jq -r .base.repo.full_name)
29-
BASE_BRANCH=$(echo "$pr_response" | jq -r .base.ref)
30-
31-
USER_LOGIN=$(jq -r ".comment.user.login" "$GITHUB_EVENT_PATH")
32-
33-
user_response=$(curl -s -H "${AUTH_HEADER}" -H "${API_HEADER}" \
34-
"${URI}/users/${USER_LOGIN}")
35-
36-
USER_NAME=$(echo "$user_response" | jq -r ".name")
37-
if [[ "$USER_NAME" == "null" ]]; then
38-
USER_NAME=$USER_LOGIN
39-
fi
40-
41-
USER_NAME="${USER_NAME} (Softfix Action)"
42-
43-
USER_EMAIL=$(echo "$user_response" | jq -r ".email")
44-
if [[ "$USER_EMAIL" == "null" ]]; then
45-
USER_EMAIL="$USER_LOGIN@users.noreply.github.com"
46-
fi
47-
48-
if [[ -z "$BASE_BRANCH" ]]; then
49-
echo "Cannot get base ref information for #$PR_NUMBER"
50-
echo "API response: $pr_response"
51-
exit 1
52-
fi
53-
54-
HEAD_REPO=$(echo "$pr_response" | jq -r .head.repo.full_name)
55-
HEAD_BRANCH=$(echo "$pr_response" | jq -r .head.ref)
56-
57-
echo "Base branch for PR #$PR_NUMBER is $BASE_BRANCH"
58-
59-
USER_TOKEN=${USER_LOGIN}_TOKEN
60-
COMMITTER_TOKEN=${!USER_TOKEN:-$GITHUB_TOKEN}
61-
62-
git remote set-url origin https://x-access-token:$COMMITTER_TOKEN@github.com/$GITHUB_REPOSITORY.git
63-
git config --global user.email "$USER_EMAIL"
64-
git config --global user.name "$USER_NAME"
65-
66-
git remote add fork https://x-access-token:$COMMITTER_TOKEN@github.com/$HEAD_REPO.git
67-
68-
set -o xtrace
69-
70-
# make sure branches are up-to-date
71-
git fetch origin $BASE_BRANCH
72-
git fetch fork $HEAD_BRANCH
73-
74-
# do the rebase
75-
git checkout -b $HEAD_BRANCH fork/$HEAD_BRANCH
76-
git reset --soft $BASE_BRANCH
77-
git commit -m "sweet"
78-
79-
# push back
80-
git push --force-with-lease fork $HEAD_BRANCH
81-
82-
83-
84-
85-
86-
87-

test/a

Whitespace-only changes.

0 commit comments

Comments
 (0)