You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Are you using this Action in a cool new way? Open a pull request to this repo to have your workflow added to the list above!
636
636
637
637
## Suggestions 🌟
638
638
639
-
This section will cover a few suggestions that will help you when using this Action
639
+
This section will cover a few suggestions and best practices that will help you when using this Action.
640
640
641
641
1. Suggest Updating Pull Request Branches - You should absolutely use this option when using the `branch-deploy` Action. This option can be found in your repository's `/settings` page
2. Enable Branch Protection Settings - It is always a good idea to enable branch protection settings for your repo, especially when using this Action
644
+
1. Require Pull Request Reviews - Enforce that pull requests have approvals, code owner approvals, and dismiss stale pull request approvals upon new commits
645
+

646
+
2. Add Required Status Checks - Enforce that certain CI checks must pass before a pull request can be merged
3. If you don't need to deploy PR forks (perhaps your project is internal and not open source), you can set the `allow_forks` input to `"false"` to prevent deployments from running on forks.
649
+
4. You should **always** (unless you have a certain restriction) use the `sha` output variable over the `ref` output variable when deploying. It is more reliable for deployments, and safer from a security perspective. More details about using commit SHAs for deployments can be found [here](./docs/deploying-commit-SHAs.md).
test('runs prechecks and finds that the IssueOps command is valid for a branch deployment',async()=>{
@@ -482,6 +486,242 @@ test('runs prechecks and finds that the IssueOps command is valid for a branch d
482
486
})
483
487
})
484
488
489
+
test('runs prechecks and finds that the IssueOps command is valid for a branch deployment and is from a forked repository and the PR is approved but CI is failing and it is a noop',async()=>{
'### ⚠️ Cannot proceed with deployment\n\n- reviewDecision: `APPROVED`\n- commitStatus: `FAILURE`\n\n> Your pull request is approved but CI checks are failing',
537
+
status: false
538
+
})
539
+
})
540
+
541
+
test('runs prechecks and finds that the IssueOps command is a fork and does not require reviews so it proceeds but with a warning',async()=>{
'🎛️ CI checks have been defined but required reviewers have not been defined',
587
+
status: true,
588
+
noopMode: false,
589
+
ref: 'abcde12345',
590
+
sha: 'abcde12345'
591
+
})
592
+
593
+
expect(warningMock).toHaveBeenCalledWith(
594
+
'🚨 pull request reviews are not enforced by this repository and this operation is being performed on a fork - this operation is dangerous! You should require reviews via branch protection settings (or rulesets) to ensure that the changes being deployed are the changes that you reviewed.'
595
+
)
596
+
})
597
+
598
+
test('runs prechecks and rejects a pull request from a forked repository because it does not have completed reviews',async()=>{
'### ⚠️ Cannot proceed with deployment\n\n- reviewDecision: `REVIEW_REQUIRED`\n\n> All deployments from forks **must** have the required reviews before they can proceed. Please ensure this PR has been reviewed and approved before trying again.',
653
+
status: false
654
+
})
655
+
656
+
expect(debugMock).toHaveBeenCalledWith(
657
+
'rejecting deployment from fork without required reviews - noopMode: false'
658
+
)
659
+
})
660
+
661
+
test('runs prechecks and rejects a pull request from a forked repository because it does not have completed reviews (noop)',async()=>{
'### ⚠️ Cannot proceed with deployment\n\n- reviewDecision: `REVIEW_REQUIRED`\n\n> All deployments from forks **must** have the required reviews before they can proceed. Please ensure this PR has been reviewed and approved before trying again.',
717
+
status: false
718
+
})
719
+
720
+
expect(debugMock).toHaveBeenCalledWith(
721
+
'rejecting deployment from fork without required reviews - noopMode: true'
722
+
)
723
+
})
724
+
485
725
test('runs prechecks and finds that the IssueOps command is on a PR from a forked repo and is not allowed',async()=>{
486
726
octokit.graphql=jest.fn().mockReturnValue({
487
727
repository: {
@@ -1593,6 +1833,10 @@ test('runs prechecks and finds that no CI checks exist but reviews are defined a
Copy file name to clipboardExpand all lines: docs/deploying-commit-SHAs.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,8 @@ Do this:
32
32
33
33
This ensures you are deploying the __exact__ commit SHA that branch-deploy has determined is safe to deploy. This is a best practice for security, reliability, and safety during deployments.
34
34
35
+
Don't worry, this is still a _branch deployment_, you are just telling your deployment process to use the __exact commit SHA__ that the branch points to rather than the branch name itself which is mutable.
36
+
35
37
## Introduction
36
38
37
39
Deploying commit SHAs (Secure Hash Algorithms) is a best practice in software development and deployment processes. This document explains the importance of deploying commit SHAs, focusing on aspects of security, reliability, and safety. It also provides an overview of how commit SHAs work under the hood in Git and how this contributes to the overall safety of the deployment process.
0 commit comments