-
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.
Add actions to maintain preview branch
Borrowed from bssw.io repo
- Loading branch information
Showing
3 changed files
with
71 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,22 @@ | ||
name: Sync main to preview | ||
|
||
# When there's a push on main, we want to reflect it on preview too. | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
jobs: | ||
sync-preview: | ||
if: github.repository_owner == 'betterscientificsoftware' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: Merge main -> preview | ||
uses: devmasx/[email protected] | ||
with: | ||
type: now | ||
head_to_merge: ${{ github.ref }} | ||
from_branch: main | ||
target_branch: preview | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
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,26 @@ | ||
name: Sync pull request to preview | ||
on: | ||
workflow_dispatch: | ||
pull_request_target: | ||
types: [opened, synchronize, labeled] | ||
jobs: | ||
sync-pull-request: | ||
if: contains(github.event.pull_request.labels.*.name, 'preview') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
with: | ||
ref: 'preview' # Not default 'main' branch | ||
- name: Merge pr -> preview | ||
uses: devmasx/[email protected] | ||
with: | ||
type: now | ||
head_to_merge: ${{ github.event.pull_request.head.sha }} | ||
target_branch: preview | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# NOTE: Above, we use the 'if' statement for looking for the 'preview' label | ||
# and then only run the job if that label is found in the PR. I tried using | ||
# the setting {label_name: 'preview'} for the `devmasx/merge-branch` action | ||
# above but it seemed to ignore it and try to merge the PR branch to 'preview' | ||
# anyway. |
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,23 @@ | ||
name: Reject pull requests on preview branch | ||
|
||
# The preview branch is specially constructed by our workflows and should never be the direct target of a | ||
# pull request. So if someone tries, we add a polite comment and close the PR. | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened, reopened] | ||
branches: | ||
- preview | ||
|
||
jobs: | ||
reject-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# This is a variant of superbrothers/close-pull-request, which only does pull_request events, | ||
# not pull_request_target events. Ideally, the capabilities will some day be merged, since | ||
# the *only* distinction is a test on the type of event! | ||
- uses: SiliconLabs/[email protected] | ||
with: | ||
comment: "The preview branch does not accept pull requests. To contribute to the CASS website make your PR against the main branch. Thanks" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |