plasma-icons: build-time generate Icon components #3979
Workflow file for this run
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
name: PR Documentation and Storybook [PR into DEV branch] | |
on: | |
pull_request: | |
branches: | |
- master | |
pull_request_target: | |
branches: | |
- dev | |
concurrency: | |
# New commit on branch cancels running workflows of the same branch | |
group: ${{ github.workflow }}-${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
authorize: | |
name: Authorize external pull request | |
if: ${{ !startsWith(github.head_ref, 'release') }} | |
uses: ./.github/workflows/authorize-external-pr.yml | |
scope: | |
needs: [ authorize ] | |
uses: ./.github/workflows/change-detection.yml | |
with: | |
as-enumeration: true | |
ref: refs/pull/${{github.event.pull_request.number}}/merge | |
secrets: inherit | |
build: | |
name: Build | |
needs: [ authorize, scope ] | |
if: ${{ needs.scope.outputs.HAS_DOCUMENTATION_CHANGED == 'true' }} | |
runs-on: ubuntu-latest | |
env: | |
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} | |
PR_NAME: pr-${{ github.event.number }} | |
ICONS_PUBLIC_URL: /icons | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
ref: refs/pull/${{github.event.pull_request.number}}/merge | |
- name: Prepare environment | |
uses: ./.github/actions/prepare-environment | |
- name: Computed scope | |
id: scope | |
uses: actions/github-script@v6 | |
env: | |
ENUMERATION: ${{ toJSON(needs.scope.outputs.PACKAGES_ENUMERATION) }} | |
with: | |
result-encoding: string | |
script: | | |
const { ENUMERATION } = process.env; | |
const enumeration = JSON.parse(JSON.parse(ENUMERATION)); | |
if (!enumeration.includes('plasma-core')) { | |
enumeration.push('plasma-core'); | |
} | |
if (!enumeration.includes('plasma-hope')) { | |
enumeration.push('plasma-hope'); | |
} | |
if (!enumeration.includes('plasma-new-hope')) { | |
enumeration.push('plasma-new-hope'); | |
} | |
if (!enumeration.includes('plasma-tokens-utils')) { | |
enumeration.push('plasma-tokens-utils'); | |
} | |
if (enumeration.includes('plasma-tokens-native') && !enumeration.includes('plasma-tokens')) { | |
enumeration.push('plasma-tokens'); | |
} | |
if (!enumeration.includes('plasma-icons')) { | |
enumeration.push('plasma-icons'); | |
} | |
if (!enumeration.includes('plasma-docs-ui')) { | |
enumeration.push('plasma-docs-ui'); | |
} | |
if (!enumeration.includes('plasma-website')) { | |
enumeration.push('plasma-website'); | |
} | |
if (enumeration.includes('plasma-website') && !enumeration.includes('plasma-b2c')) { | |
enumeration.push('plasma-b2c'); | |
} | |
if (enumeration.includes('plasma-ui-docs')) { | |
enumeration.push('plasma-web'); | |
} | |
if (!enumeration.includes('plasma-typo')) { | |
enumeration.push('plasma-typo'); | |
} | |
return enumeration.join(','); | |
- name: Lerna bootstrap | |
run: npx lerna bootstrap --scope=@salutejs/{${{steps.scope.outputs.result}}} | |
- name: Prepare directory | |
run: mkdir -p s3_build/${PR_NAME} | |
# TODO: https://github.com/salute-developers/plasma/issues/603 | |
- name: Plasma Website | |
run: | | |
export NODE_OPTIONS=--openssl-legacy-provider | |
npm run build --prefix="./website/plasma-website" | |
cp -R ./website/plasma-website/build/. ./s3_build/${PR_NAME} | |
- name: Plasma UI Docs | |
if: ${{ needs.scope.outputs.HAS_PLASMA_UI_DOCS == 'true' && needs.scope.outputs.HAS_PLASMA_UI == 'true' }} | |
run: | | |
npm run build --prefix="./website/plasma-ui-docs" | |
cp -R ./website/plasma-ui-docs/build ./s3_build/${PR_NAME}/ui | |
- name: Plasma Web Docs | |
if: ${{ needs.scope.outputs.HAS_PLASMA_WEB_DOCS == 'true' }} | |
run: | | |
npm run build --prefix="./website/plasma-web-docs" | |
cp -R ./website/plasma-web-docs/build ./s3_build/${PR_NAME}/web | |
- name: Plasma SDDS-SERV Docs | |
if: ${{ needs.scope.outputs.HAS_SDDS_SERV == 'true' }} | |
run: | | |
npm run build --prefix="./website/sdds-serv-docs" | |
cp -R ./website/sdds-serv-docs/build ./s3_build/${PR_NAME}/sdds-serv | |
- name: Plasma UI Storybook | |
if: ${{ needs.scope.outputs.HAS_PLASMA_UI == 'true' }} | |
run: | | |
npm run storybook:build --prefix="./packages/plasma-ui" | |
cp -R ./packages/plasma-ui/build-sb ./s3_build/${PR_NAME}/ui-storybook | |
- name: Plasma Web Storybook | |
if: ${{ needs.scope.outputs.HAS_PLASMA_WEB == 'true' }} | |
run: | | |
npm run storybook:build --prefix="./packages/plasma-web" | |
cp -R ./packages/plasma-web/build-sb ./s3_build/${PR_NAME}/web-storybook | |
- name: Plasma B2C Storybook | |
if: ${{ needs.scope.outputs.HAS_PLASMA_B2C == 'true' }} | |
run: | | |
npm run storybook:build --prefix="./packages/plasma-b2c" | |
cp -R ./packages/plasma-b2c/build-sb ./s3_build/${PR_NAME}/b2c-storybook | |
- name: Plasma "New Hope" Storybook | |
if: ${{ needs.scope.outputs.HAS_PLASMA_HOPE == 'true' }} | |
run: | | |
npm run storybook:build --prefix="./packages/plasma-new-hope" | |
cp -R ./packages/plasma-new-hope/build-sb ./s3_build/${PR_NAME}/new-hope-storybook | |
- name: Plasma "ASDK" Storybook | |
if: ${{ needs.scope.outputs.HAS_PLASMA_ASDK == 'true' }} | |
run: | | |
npm run storybook:build --prefix="./packages/plasma-asdk" | |
cp -R ./packages/plasma-asdk/build-sb ./s3_build/${PR_NAME}/asdk-storybook | |
- name: Plasma "Caldera" Storybook | |
if: ${{ needs.scope.outputs.HAS_CALDERA == 'true' }} | |
run: | | |
npm run storybook:build --prefix="./packages/caldera" | |
cp -R ./packages/caldera/build-sb ./s3_build/${PR_NAME}/caldera-storybook | |
- name: Plasma "Caldera-online" Storybook | |
if: ${{ needs.scope.outputs.HAS_CALDERA_ONLINE == 'true' }} | |
run: | | |
npm run storybook:build --prefix="./packages/caldera-online" | |
cp -R ./packages/caldera-online/build-sb ./s3_build/${PR_NAME}/caldera-online-storybook | |
- name: Plasma "SDDS SERV" Storybook | |
if: ${{ needs.scope.outputs.HAS_SDDS_SERV == 'true' }} | |
run: | | |
npm run storybook:build --prefix="./packages/sdds-serv" | |
cp -R ./packages/sdds-serv/build-sb ./s3_build/${PR_NAME}/sdds-serv-storybook | |
- name: Install s3cmd | |
run: pip3 install s3cmd | |
- name: s3 Upload builds | |
run: > | |
s3cmd | |
--access_key ${{ secrets.AWS_ACCESS_KEY_ID }} | |
--secret_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
--host ${{ secrets.AWS_ENDPOINT }} | |
--host-bucket ${{ secrets.AWS_ENDPOINT }} | |
--bucket-location ${{ secrets.AWS_REGION }} | |
--signature-v2 | |
--delete-removed | |
--no-mime-magic | |
sync | |
./s3_build/${PR_NAME}/ | |
s3://${{ secrets.AWS_S3_BUCKET_2 }}/pr/${PR_NAME}/ | |
- name: Post success comment | |
uses: actions/github-script@v6 | |
env: | |
HAS_PLASMA_B2C: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_B2C) }} | |
HAS_PLASMA_WEB: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_WEB) }} | |
HAS_PLASMA_UI: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_UI) }} | |
HAS_PLASMA_HOPE: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_HOPE) }} | |
HAS_PLASMA_ASDK: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_ASDK) }} | |
HAS_CALDERA: ${{ fromJSON(needs.scope.outputs.HAS_CALDERA) }} | |
HAS_CALDERA_ONLINE: ${{ fromJSON(needs.scope.outputs.HAS_CALDERA_ONLINE) }} | |
HAS_SDDS_SERV: ${{ fromJSON(needs.scope.outputs.HAS_SDDS_SERV) }} | |
with: | |
github-token: ${{secrets.GH_TOKEN}} | |
script: | | |
const { HAS_PLASMA_B2C, HAS_PLASMA_WEB, HAS_PLASMA_UI, HAS_PLASMA_HOPE, HAS_PLASMA_ASDK, HAS_CALDERA, HAS_CALDERA_ONLINE, HAS_SDDS_SERV } = process.env; | |
const { | |
issue: { number }, | |
repo: { owner, repo } | |
} = context; | |
const links = [ | |
`website: http://plasma.sberdevices.ru/pr/pr-${number}/` | |
]; | |
if (HAS_PLASMA_B2C === 'true') { | |
links.push(`b2c storybook: http://plasma.sberdevices.ru/pr/pr-${number}/b2c-storybook/`) | |
} | |
if (HAS_PLASMA_WEB === 'true') { | |
links.push(`web storybook: http://plasma.sberdevices.ru/pr/pr-${number}/web-storybook/`) | |
} | |
if (HAS_PLASMA_UI === 'true') { | |
links.push(`ui storybook: http://plasma.sberdevices.ru/pr/pr-${number}/ui-storybook/`) | |
} | |
if (HAS_PLASMA_HOPE === 'true') { | |
links.push(`new-hope storybook: http://plasma.sberdevices.ru/pr/pr-${number}/new-hope-storybook/`) | |
} | |
if (HAS_PLASMA_ASDK === 'true') { | |
links.push(`asdk storybook: http://plasma.sberdevices.ru/pr/pr-${number}/asdk-storybook/`) | |
} | |
if (HAS_CALDERA === 'true') { | |
links.push(`caldera storybook: http://plasma.sberdevices.ru/pr/pr-${number}/caldera-storybook/`) | |
} | |
if (HAS_CALDERA_ONLINE === 'true') { | |
links.push(`caldera-online storybook: http://plasma.sberdevices.ru/pr/pr-${number}/caldera-online-storybook/`) | |
} | |
if (HAS_SDDS_SERV === 'true') { | |
links.push(`sdds-serv storybook: http://plasma.sberdevices.ru/pr/pr-${number}/sdds-serv-storybook/`) | |
} | |
github.rest.issues.createComment({ | |
issue_number: number, | |
owner, | |
repo, | |
body: `Documentation preview deployed! | |
${links.join('\n')} | |
` | |
}); |