Skip to content

Storybook CI

Storybook CI #12

Workflow file for this run

# v1.0.0.vcmp
name: Storybook CI
on:
workflow_dispatch:
workflow_call:
# push:
# branches:
# [main]
# paths-ignore:
# - '.idea'
# - '.vscode'
# - 'README.md'
# - 'LICENSE'
# pull_request:
# paths-ignore:
# - '.idea'
# - '.vscode'
# - 'README.md'
# - 'LICENSE'
jobs:
ci:
# if: ${{ github.actor != 'dependabot[bot]' &&
# (github.event.pull_request.head.repo.full_name == github.repository ||
# github.event.pull_request.head.repo.full_name == '') }} # Check that PR not from forked repo and not from Dependabot
runs-on: ubuntu-latest
env:
FORCE_COLOR: true
CLOUD_INSTANCE_BASE_URL: ${{secrets.CLOUD_INSTANCE_BASE_URL}}
CLIENT_ID: ${{secrets.CLIENT_ID}}
CLIENT_SECRET: ${{secrets.CLIENT_SECRET}}
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
# BLOB_SAS: ${{ secrets.BLOB_TOKEN }}
VERSION: ''
VERSION_SUFFIX: ''
BUILD_STATE: 'failed'
RELEASE_STATUS: 'false'
DOCKER_URL: ''
DOCKER_REPOSITORY: 'ghcr.io'
DOCKER_IMAGE: 'vc-shell-storybook'
DOCKER_TAG: ''
outputs:
jira-keys: ${{ steps.jira_keys.outputs.jira-keys }}
version: ${{ steps.image.outputs.shortVersion }}
tag: ${{ env.DOCKER_TAG }}
steps:
- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Enable corepack
run: |
corepack enable
- name: Set RELEASE_STATUS
# if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
if: ${{ github.ref == 'refs/heads/main' }}
run: |
echo "RELEASE_STATUS=true" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Image Version
uses: VirtoCommerce/vc-github-actions/get-image-version@master
id: image
with:
releaseBranch: main
projectType: theme
- name: Set release VERSION_SUFFIX
run: |
echo "VERSION_SUFFIX=${{ steps.image.outputs.suffix }}" >> $GITHUB_ENV
- name: Set release-alpha VERSION_SUFFIX
# if: ${{ github.event_name == 'workflow_dispatch' }}
if: ${{ github.event_name != 'refs/heads/main' }}
run: |
echo "VERSION_SUFFIX=${{ steps.image.outputs.fullSuffix }}" >> $GITHUB_ENV
# - name: Set PR VERSION_SUFFIX
# if: ${{ github.event_name == 'pull_request' }}
# run: |
# echo "VERSION_SUFFIX=${{ steps.image.outputs.suffix }}-${{ steps.image.outputs.SHA }}" >> $GITHUB_ENV
- name: Set VERSION
run: |
echo "VERSION=${{ steps.image.outputs.prefix }}${{ env.VERSION_SUFFIX && '-' || '' }}${{ env.VERSION_SUFFIX }}" >> $GITHUB_ENV
- name: Update package.json Version
run: |
yarn version ${{ env.VERSION }}
- name: Set DOCKER_TAG variable
run: |
if [ '${{ github.ref }}' = 'refs/heads/main' ]; then
echo "DOCKER_TAG=${{ steps.image.outputs.shortVersion }}" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ steps.image.outputs.taggedVersion }}" >> $GITHUB_ENV
fi;
- name: Install dependencies
run: |
yarn install
- name: Build
run: |
yarn storybook-build
- name: BUILD_STATE::successful
if: success()
run: echo "BUILD_STATE=successful" >> $GITHUB_ENV
- name: Packaging
run: |
yarn storybook-compress
# - name: Publish to Blob
# # if: ${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main'}}
# if: ${{ github.ref != 'refs/heads/main'}}
# id: blobRelease
# uses: VirtoCommerce/vc-github-actions/publish-blob-release@master
# with:
# blobSAS: ${{ secrets.BLOB_TOKEN }}
- name: Set URLs
id: urls
run: |
echo "DOCKER_URL=${{ env.DOCKER_REPOSITORY }}/${GITHUB_REPOSITORY_OWNER,,}/${{ env.DOCKER_IMAGE }}:" >> $GITHUB_OUTPUT
# echo "BLOB_URL=${{ steps.blobRelease.outputs.packageUrl }}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REPOSITORY }}
username: $GITHUB_ACTOR
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: ${{ github.ref == 'refs/heads/main' || github.event_name == 'pull_request' || github.ref == 'refs/heads/VCI-847-1' }} ### TODO remove extra branch
context: .
file: .storybook/Dockerfile
tags: ${{ steps.urls.outputs.DOCKER_URL }}${{ env.DOCKER_TAG }},${{ steps.urls.outputs.DOCKER_URL }}${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' && 'dev-latest' || 'latest'}}
- name: Parse Jira Keys from All Commits
uses: VirtoCommerce/vc-github-actions/get-jira-keys@master
if: always()
id: jira_keys
with:
release: ${{ env.RELEASE_STATUS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push Build Info to Jira
if: ${{ env.CLOUD_INSTANCE_BASE_URL != 0 && env.CLIENT_ID != 0 && env.CLIENT_SECRET != 0 && steps.jira_keys.outputs.jira-keys != '' && always() }}
id: push_build_info_to_jira
uses: VirtoCommerce/jira-upload-build-info@master
with:
cloud-instance-base-url: '${{ secrets.CLOUD_INSTANCE_BASE_URL }}'
client-id: '${{ secrets.CLIENT_ID }}'
client-secret: '${{ secrets.CLIENT_SECRET }}'
pipeline-id: '${{ github.repository }} ${{ github.workflow }}'
build-number: ${{ github.run_number }}
build-display-name: 'Workflow: ${{ github.workflow }} (#${{ github.run_number }})'
build-state: '${{ env.BUILD_STATE }}'
build-url: '${{github.event.repository.url}}/actions/runs/${{github.run_id}}'
update-sequence-number: '${{ github.run_id }}'
last-updated: '${{github.event.head_commit.timestamp}}'
issue-keys: '${{ steps.jira_keys.outputs.jira-keys }}'
commit-id: '${{ github.sha }}'
repo-url: '${{ github.event.repository.url }}'
build-ref-url: '${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}'
- name: Confirm Jira Build Output
if: success()
run: |
echo "Jira Upload Build Info response: ${{ steps.push_build_info_to_jira.outputs.response }}"
cd:
runs-on: ubuntu-latest
needs: 'ci'
env:
ARGO_APP_NAME: vcmp-dev
STORYBOOK_TAG: ${{ needs.ci.outputs.tag }}
CLOUD_URL: https://portal.virtocommerce.cloud
CLOUD_TOKEN: ${{ secrets.VCMP_PLATFORM_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install vc-build
run: |
dotnet tool install --global VirtoCommerce.GlobalTool
# - name: Get theme version
# id: storybook-version
# run: |
# echo "STORYBOOK_TAG=$(cat ./storybook/image.json | jq -r '.Tag')" >> $GITHUB_ENV
- name: Update environment
run: |
dotnet tool install --global VirtoCommerce.GlobalTool
vc-build CloudEnvSetParameter -CloudUrl ${{ env.CLOUD_URL }} -CloudToken ${{ env.CLOUD_TOKEN }} -EnvironmentName ${{ env.ARGO_APP_NAME }} -HelmParameters custom.app1.image.tag=${{ env.STORYBOOK_TAG }}
- name: Check deployment start
run: |
vc-build CloudEnvStatus -CloudUrl ${{ env.CLOUD_URL }} -CloudToken ${{ env.CLOUD_TOKEN }} -EnvironmentName ${{ env.ARGO_APP_NAME }} -HealthStatus Progressing
- name: Check deployment status
run: |
vc-build CloudEnvStatus -CloudUrl ${{ env.CLOUD_URL }} -CloudToken ${{ env.CLOUD_TOKEN }} -EnvironmentName ${{ env.ARGO_APP_NAME }} -HealthStatus Healthy -SyncStatus Synced