Skip to content

Commit

Permalink
feat: Update workflows for merge to main (#555)
Browse files Browse the repository at this point in the history
* fix: worklfows for the vue3.x to main merge

* ci: fix yaml syntax
  • Loading branch information
pghorpade authored Jul 11, 2024
1 parent 3a03cbb commit d31e3b5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 12 deletions.
38 changes: 31 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ name: Run CI Suite

on:
push:
branches: [ vue3.x ]
branches:
- main
- vue3.x
pull_request:
branches: [ vue3.x ]
branches:
- main
- vue3.x

# Cancel this run if a newer commit is pushed
concurrency:
Expand Down Expand Up @@ -61,6 +65,26 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/setup-workspace
- name: Sets env vars for vue3.x merge
run: |
echo "NETLIFY_SITE_ID=${{secrets.NETLIFY_SITE_ID_STORYBOOK_VUE3X}}" >> $GITHUB_ENV
echo "PERCY_TOKEN=${{secrets.PERCY_TOKEN_STORYBOOK_VUE3X}}" >> $GITHUB_ENV
if: github.ref_name=='vue3.x'
- name: Sets env vars for main merge
run: |
echo "NETLIFY_SITE_ID=${{secrets.NETLIFY_SITE_ID_STORYBOOK}}" >> $GITHUB_ENV
echo "PERCY_TOKEN=${{secrets.PERCY_TOKEN_STORYBOOK}}" >> $GITHUB_ENV
if: github.ref_name=='main'
- name: Set environment variables for PR preview
run: |
if [[ "${{ github.base_ref }}" == "vue3.x" ]]; then
echo "NETLIFY_SITE_ID=${{ secrets.NETLIFY_SITE_ID_STORYBOOK_VUE3X }}" >> $GITHUB_ENV
echo "PERCY_TOKEN=${{ secrets.PERCY_TOKEN_STORYBOOK_VUE3X }}" >> $GITHUB_ENV
elif [[ "${{ github.base_ref }}" == "main" ]]; then
echo "NETLIFY_SITE_ID=${{ secrets.NETLIFY_SITE_ID_STORYBOOK }}" >> $GITHUB_ENV
echo "PERCY_TOKEN=${{ secrets.PERCY_TOKEN_STORYBOOK }}" >> $GITHUB_ENV
fi
if: github.event_name == 'pull_request'
- name: Cache Storybook Build
id: cache-storybook
uses: actions/cache@v3
Expand All @@ -69,7 +93,7 @@ jobs:
key: storybook-${{ github.sha }}
- run: pnpm run build-storybook
- name: Deploy to Netlify (merged)
if: github.ref_name=='vue3.x'
if: github.ref_name == 'main' || github.ref_name == 'vue3.x'
uses: nwtgck/actions-netlify@v2 # v1.2.3
with:
production-deploy: true
Expand All @@ -80,9 +104,9 @@ jobs:
github-deployment-environment: test
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_STORYBOOK_VUE3X }}
NETLIFY_SITE_ID: ${{ env.NETLIFY_SITE_ID }}
- name: Deploy to Netlify (preview)
if: github.ref_name!='main'
if: github.event_name == 'pull_request'
uses: nwtgck/actions-netlify@v2 # v1.2.3
with:
production-deploy: false
Expand All @@ -95,11 +119,11 @@ jobs:
github-deployment-environment: storybook--${{ github.event_name }}-${{ github.event.number }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_STORYBOOK_VUE3X }}
NETLIFY_SITE_ID: ${{ env.NETLIFY_SITE_ID }}
- name: Cypress test for Storybook Components
uses: cypress-io/github-action@v5
with:
start: pnpm dlx http-server ./storybook-static -p 6006
wait-on: http://localhost:6006
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_STORYBOOK_VUE3X }}
PERCY_TOKEN: ${{ env.PERCY_TOKEN }}
30 changes: 25 additions & 5 deletions .github/workflows/percy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,38 @@ name: Submit screenshots to Percy for visual regression testing.

on:
push:
branches: [ vue3.x ]
branches:
- main
- vue3.x
workflow_dispatch:
inputs: {}
inputs:
target-branch:
description: 'Select target branch for Percy screenshots'
required: true
default: 'main'
type: choice
options:
- main
- vue3.x

jobs:
percy:
name: Percy - Storybook Components3.x
name: Percy - Storybook Components
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/setup-workspace # why cant cypress percy command access this pnpm cache
- name: Set Percy environment variables
run: |
if [[ "${{ github.ref_name }}" == "vue3.x" || "${{ github.event.inputs.target-branch }}" == "vue3.x" ]]; then
echo "PERCY_TOKEN=${{ secrets.PERCY_TOKEN_STORYBOOK_VUE3X }}" >> $GITHUB_ENV
echo "PERCY_TARGET_BRANCH=vue3.x" >> $GITHUB_ENV
else
echo "PERCY_TOKEN=${{ secrets.PERCY_TOKEN_STORYBOOK }}" >> $GITHUB_ENV
echo "PERCY_TARGET_BRANCH=main" >> $GITHUB_ENV
fi
if: always()
- name: Use cached storybook build
id: cache-storybook
uses: actions/cache@v3
Expand All @@ -33,6 +53,6 @@ jobs:
command-prefix: 'percy exec -- pnpx'
wait-on: http://localhost:6006
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_STORYBOOK_VUE3X }}
PERCY_TARGET_BRANCH: vue3.x
PERCY_TOKEN: ${{ env.PERCY_TOKEN }}
PERCY_TARGET_BRANCH: ${{ env.PERCY_TARGET_BRANCH }}

1 comment on commit d31e3b5

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.