Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
gkuga committed Dec 20, 2021
1 parent 3d08bcb commit 4e49f59
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,47 @@ jobs:
ACTIONS_STEP_DEBUG: true
with:
commit-message: "Just testing [skip ci]"

updatePRTitleAndBody:
name: "[TEST] Update PR title and body"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- run: "date > test.txt"
- run: "npm ci"
- run: "npm run build"
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
title: Test pull request
body: This pull request is part of the CI - please ignore.
branch: test-update-pr-title-and-body
commit-message: "Just testing [skip ci]"
- run: "echo updated >> test.txt"
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
title: Skipped Updated test pull request
body: This Skipped updated pull request is part of the CI - please ignore.
branch: test-update-pr-title-and-body
commit-message: "Just testing [skip ci]"
- run: "echo updated >> test.txt"
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
title: Updated test pull request
body: This updated pull request is part of the CI - please ignore.
branch: test-update-pr-title-and-body
commit-message: "Just testing [skip ci]"
update-pull-request-title-and-body: true
- run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git :test-update-pr-title-and-body"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,19 @@ async function main() {
if (data.total_count > 0) {
const { number } = data.items[0]
core.info(
`Existing pull request for branch "${inputs.branch}" updated: #${number})`
`Existing pull request for branch "${inputs.branch}" updated: (#${number})`
);
if (!inputs.updatePRTitleAndBody) return
if (inputs.updatePRTitleAndBody === false || inputs.updatePRTitleAndBody === 'false') return
await octokit.request(`POST /repos/{owner}/{repo}/pulls/{number}`, {
owner,
repo,
number,
title: inputs.title,
body: inputs.body,
});
core.info(
`PR title and body are updated`
);
return;
}
}
Expand Down

0 comments on commit 4e49f59

Please sign in to comment.