Skip to content

HDS-2603 and HDS-2605 Link renewals #383

HDS-2603 and HDS-2605 Link renewals

HDS-2603 and HDS-2605 Link renewals #383

Workflow file for this run

name: build
on:
workflow_dispatch:
pull_request:
push:
branches:
- development
- master
- release-*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Read .nvmrc
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT
id: nvmrc
- name: setup node ${{ steps.nvmrc.outputs.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: '${{ steps.nvmrc.outputs.NODE_VERSION }}'
registry-url: 'https://registry.npmjs.org'
# Github cache
- name: get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: restore yarn cache
uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-cache-folder-
- name: restore lerna
uses: actions/cache@v4
with:
path: '**/node_modules'
key: yarn-node_modules-folder-${{ hashFiles('**/yarn.lock') }}
- name: install dependencies
run: |
yarn config set network-timeout 300000
yarn --frozen-lockfile --ignore-scripts
- name: build design tokens package
run: yarn build
working-directory: ./packages/design-tokens
- name: build core package
run: yarn build
working-directory: ./packages/core
- name: build react package
run: yarn build
working-directory: ./packages/react
- name: test react package
run: yarn test
working-directory: ./packages/react
- name: build hds-js package
run: yarn build:hds-js
working-directory: ./packages/react
- name: build standalone hds-js package
run: yarn build:hds-js-standalone
working-directory: ./packages/react
- name: build storybook for core
run: yarn build-storybook
working-directory: ./packages/core
- name: build storybook for react
run: yarn build-storybook
working-directory: ./packages/react
- name: Store all artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ github.sha }}
path: |
packages/hds-js/lib
packages/hds-js/standalone
packages/design-tokens/lib
packages/core/lib
packages/core/storybook-static
packages/react/lib
packages/react/storybook-static
# packages/react/.loki/reference
# packages/react/.lokirc.json
retention-days: 1
include-hidden-files: true
run-loki-tests:
needs: build
uses: ./.github/workflows/loki-tests.yml
with:
commit_sha: ${{ github.sha }}
run-e2e-tests:
needs: build
uses: ./.github/workflows/e2e-tests.yml
with:
commit_sha: ${{ github.sha }}
publish-demo-site-with-storybooks:
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/development' || startsWith(github.ref, 'refs/heads/release-'))) ||
(github.event_name == 'pull_request' && (github.base_ref == 'development' || github.base_ref == 'master'))
needs: [build, run-loki-tests, run-e2e-tests]
uses: ./.github/workflows/publish-demo-site-with-storybooks.yml
with:
commit_sha: ${{ github.sha }}
build_single_version: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.base_ref == 'development') }}
secrets:
HDSDEMO_SSH_DEPLOY_KEY: ${{ secrets.HDSDEMO_SSH_DEPLOY_KEY }}
publish-site-with-storybooks:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [build, run-loki-tests, run-e2e-tests]
uses: ./.github/workflows/publish-site-with-storybooks.yml
with:
commit_sha: ${{ github.sha }}
secrets:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish-npm-packages:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [build, run-loki-tests, run-e2e-tests]
uses: ./.github/workflows/publish-npm-packages.yml
with:
commit_sha: ${{ github.sha }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
delete-artifacts-after-success:
needs: [build, run-loki-tests, run-e2e-tests, publish-demo-site-with-storybooks, publish-site-with-storybooks, publish-npm-packages]
if: |
always() &&
(needs.build.result == 'success') &&
(needs.run-loki-tests.result == 'success') &&
(needs.run-e2e-tests.result == 'success') &&
(needs.publish-demo-site-with-storybooks.result == 'success' || needs.publish-demo-site-with-storybooks.result == 'skipped') &&
(needs.publish-site-with-storybooks.result == 'success' || needs.publish-site-with-storybooks.result == 'skipped') &&
(needs.publish-npm-packages.result == 'success' || needs.publish-npm-packages.result == 'skipped')
runs-on: ubuntu-latest
steps:
- name: Delete artifacts
uses: actions/github-script@v7
with:
script: |
const artifacts = await github.rest.actions.listArtifactsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
name: `build-${context.sha}`
});
for (const artifact of artifacts.data.artifacts) {
await github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id
});
}