Skip to content

Commit

Permalink
PWA-1219: Reusable Deployment Workflow (#76)
Browse files Browse the repository at this point in the history
* Add package

* Add docs

* Change input token

* Update input namespace

* Fix composition structure

* Remove env

* Fix indent

* Fix composite

* Fix composition

* Composition

* Add shell

* Shell

* Update token input

* Input naming/docs

* Remove actor
  • Loading branch information
jmurphy-res authored Jan 3, 2024
1 parent 518f323 commit a01d407
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The following are our current actions. Go to its directories for a more detailed
| [twistlock](/twistlock) | Run twistlock on repository | Active |
| [publish-releases](/publish-releases) | Bump version and publish packages that have been modified. | Active |
| [publish-previews](/publish-previews) | Publish preview package(s) from pull request. | Active |
| [web-create-release-pr](/web-create-release-pr) | Creates a release candidate branch and pull request (PR) | Active |
| [auth0-add-origin](/auth0-add-origin) | Add a URL (such as a preview URL) to an Auth0 Client | Deprecated |
| [auth0-remove-origin](/auth0-remove-origin) | Remove a URL (such as a preview URL) from an Auth0 Client | Deprecated |

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"auth0-remove-origin",
"twistlock",
"start-and-check",
"web-create-release-pr",
"core/*"
]
},
Expand Down
24 changes: 24 additions & 0 deletions web-create-release-pr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Web - Create Release PR

Creates a release candidate branch and pull request (PR)

## Usage

```yaml
name: Prod - Create Release Candidate

on:
workflow_dispatch:

env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}

jobs:
create-release-pr:
uses: resideo/actions/web-create-release-pr@master
with:
fromBranch: stage
toBranch: master
rcBranchPrefix: release
prLabel: Prod Release
```
77 changes: 77 additions & 0 deletions web-create-release-pr/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Create Release Candidate

inputs:
fromBranch:
description: 'Source branch name. Ex: develop'
required: true
type: string
toBranch:
description: 'Destination branch name. Ex: stage'
required: true
type: string
rcBranchPrefix:
description: 'RC branch prefix name. Ex: stage-release'
required: true
type: string
prLabel:
description: 'Pull request label. Ex: STAGE RELEASE'
required: true
type: string
githubToken:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'

runs:
using: "composite"
steps:
- name: Checkout ๐Ÿ›Ž๏ธ
uses: actions/checkout@v3
with:
token: ${{ inputs.githubToken }}

- uses: volta-cli/action@v1

- name: Set RC Branch Name
shell: bash
run: echo "rc_branch=$(date +${{ inputs.rcBranchPrefix }}/%Y.%m.%d.%H%M)" >> $GITHUB_ENV

- name: Create RC Branch ๐Ÿ› 
shell: bash
run: |
git fetch --all --unshallow
git checkout ${{ inputs.fromBranch }}
git pull
git checkout ${{ inputs.toBranch }}
git checkout -b ${{ env.rc_branch }}
git merge ${{ inputs.fromBranch }}
git push --set-upstream origin ${{ env.rc_branch }}
- name: Generate Pull Request Body
shell: bash
run: |
echo "๐Ÿ‘‘ An automated PR to merge *${{ inputs.fromBranch }}* to *${{ inputs.toBranch }}* ๐Ÿ‘‘" > pr_msg
- name: Get Pull Request Body
id: vars
shell: bash
run: echo ::set-output name=pr_body::$(cat pr_msg)

- name: Create Pull Request ๐Ÿ› 
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ env.rc_branch }}
destination_branch: ${{ inputs.toBranch }}
pr_title: '(Stage) ${{ env.rc_branch }} '
pr_body: ${{ steps.vars.outputs.pr_body }}
pr_label: ${{ inputs.prLabel }}

- name: Get Pull Request Number
id: pr-number
shell: bash
run: echo "pull_request_number=$(gh pr view --json number -q .number || echo "")" >> $GITHUB_OUTPUT

- name: Comment on Pull Request
id: pr-comment
shell: bash
run: |
gh pr comment ${{ steps.pr-number.outputs.pull_request_number }} --body "Merge this PR manually by selecting '**Create a merge commit**' *not* 'Squash and merge'"

0 comments on commit a01d407

Please sign in to comment.