-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add handle-release-branches-workflow
- Assuming "latest" is 6.3 & "next" is 6.4... - On push to `main` - Use webhook to kick off production frontpage deploy - On push to `next` - Creates & force-pushes `release-6-4` branch - Sends dispatch event to frontpage repo to create `release-6-4` branch - On push to `release-x-x` - If pushing to `release-6-4` - Warns that changes will be lost on next push to `next` - Else - Sends dispatch event to frontpage repo to create `release-n-n` branch - Remove `build-frontpage` script - Remove references from teamcity & circleci configs
- Loading branch information
Showing
4 changed files
with
131 additions
and
68 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
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,131 @@ | ||
name: Handle Release Branches | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
branch-checks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: get-branch | ||
run: | | ||
BRANCH=($(echo ${{ github.ref }} | sed -E 's/refs\/heads\///')) | ||
echo "branch=$BRANCH" >> $GITHUB_ENV | ||
outputs: | ||
branch: ${{ env.branch }} | ||
is-latest-branch: ${{ env.branch == 'main' }} | ||
is-next-branch: ${{ env.branch == 'next' }} | ||
is-release-branch: ${{ startsWith(env.branch, 'release-') }} | ||
is-actionable-branch: ${{ env.branch == 'main' || env.branch == 'next' || startsWith(env.branch, 'release-') }} | ||
|
||
handle-latest: | ||
needs: branch-checks | ||
if: ${{ needs.branch-checks.outputs.is-latest-branch == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- run: curl -X POST "https://api.netlify.com/build_hooks/${{ secrets.FRONTPAGE_HOOK }}" | ||
|
||
get-latest-release-branch: | ||
needs: branch-checks | ||
if: ${{ needs.branch-checks.outputs.is-release-branch == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
path: main | ||
|
||
- id: latest-version | ||
uses: notiz-dev/github-action-json-property@release | ||
with: | ||
path: ${{ github.workspace }}/main/docs/versions/latest.json | ||
prop_path: version | ||
|
||
- run: | | ||
LATEST_RELEASE_BRANCH=($(echo ${{ steps.latest-version.outputs.prop }} | sed -E 's/([0-9]+)\.([0-9]+).*/release-\1-\2/')) | ||
echo "latest-release-branch=$LATEST_RELEASE_BRANCH" >> $GITHUB_ENV | ||
outputs: | ||
branch: ${{ env.latest-release-branch }} | ||
|
||
get-next-release-branch: | ||
needs: branch-checks | ||
if: ${{ needs.branch-checks.outputs.is-next-branch == 'true' || needs.branch-checks.outputs.is-release-branch == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: next | ||
path: next | ||
|
||
- id: next-version | ||
uses: notiz-dev/github-action-json-property@release | ||
with: | ||
path: ${{ github.workspace }}/next/docs/versions/next.json | ||
prop_path: version | ||
|
||
- run: | | ||
NEXT_RELEASE_BRANCH=($(echo ${{ steps.next-version.outputs.prop }} | sed -E 's/([0-9]+)\.([0-9]+).*/release-\1-\2/')) | ||
echo "next-release-branch=$NEXT_RELEASE_BRANCH" >> $GITHUB_ENV | ||
outputs: | ||
branch: ${{ env.next-release-branch }} | ||
|
||
create-next-release-branch: | ||
needs: [branch-checks, get-next-release-branch] | ||
if: ${{ needs.branch-checks.outputs.is-next-branch == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- run: | | ||
git branch temp | ||
git push -f origin temp:${{ needs.get-next-release-branch.outputs.branch }} | ||
git branch -D temp | ||
outputs: | ||
branch: ${{ needs.get-next-release-branch.outputs.branch }} | ||
|
||
latest-or-next-release-branch-check: | ||
if: ${{ always() }} | ||
needs: [branch-checks, get-latest-release-branch, get-next-release-branch] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: | | ||
IS_LATEST_RELEASE_BRANCH=${{ needs.branch-checks.outputs.branch == needs.get-latest-release-branch.outputs.branch }} | ||
IS_NEXT_RELEASE_BRANCH=${{ needs.branch-checks.outputs.branch == needs.get-next-release-branch.outputs.branch }} | ||
echo "is-latest-release-branch=$IS_LATEST_RELEASE_BRANCH" >> $GITHUB_ENV | ||
echo "is-next-release-branch=$IS_NEXT_RELEASE_BRANCH" >> $GITHUB_ENV | ||
- run: | | ||
IS_LATEST_OR_NEXT_RELEASE_BRANCH=${{ env.is-latest-release-branch == 'true' || env.is-next-release-branch == 'true' }} | ||
echo "is-latest-or-next-release-branch=$IS_LATEST_OR_NEXT_RELEASE_BRANCH" >> $GITHUB_ENV | ||
- if: ${{ env.is-latest-release-branch == 'true' }} | ||
run: echo "relevant-base-branch=main" >> $GITHUB_ENV | ||
|
||
- if: ${{ env.is-next-release-branch == 'true' }} | ||
run: echo "relevant-base-branch=next" >> $GITHUB_ENV | ||
|
||
- if: ${{ env.is-latest-or-next-release-branch == 'true' }} | ||
run: | | ||
echo 'WARNING: Do not push directly to the `${{ needs.branch-checks.outputs.branch }}` branch. This branch is created and force-pushed over after pushing to the `${{ env.relevant-base-branch }}` branch and the changes you just pushed will be lost.' | ||
exit 1 | ||
outputs: | ||
check: ${{ env.is-latest-or-next-release-branch }} | ||
|
||
request-create-frontpage-branch: | ||
if: ${{ always() }} | ||
needs: | ||
[ | ||
branch-checks, | ||
latest-or-next-release-branch-check, | ||
create-latest-release-branch, | ||
create-next-release-branch, | ||
] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- if: ${{ needs.branch-checks.outputs.is-actionable-branch == 'true' && needs.latest-or-next-release-branch-check.outputs.check == 'false' }} | ||
run: | | ||
curl -X POST https://api.github.com/repos/storybookjs/frontpage/dispatches \ | ||
-H 'Accept: application/vnd.github.v3+json' \ | ||
-u ${{ secrets.FRONTPAGE_ACCESS_TOKEN }} \ | ||
--data '{"event_type": "request-create-frontpage-branch", "client_payload": { "branch": "${{ needs.create-latest-release-branch.outputs.branch || needs.create-next-release-branch.outputs.branch || needs.branch-checks.outputs.branch }}" }}' |
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
This file was deleted.
Oops, something went wrong.