Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
source/fonts/**/sources/
helpers/test.js
tests/backstop_data/engine_scripts/
out/**
dist/**
**/*.min.js
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true
},
extends: ['eslint:recommended'],
rules: {
'no-console': 'error'
}
};
18 changes: 18 additions & 0 deletions .github/actions/cancel-workflow/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: "Cancel Workflow"
description: "Cancel this workflow on failure"
inputs:
token:
description: "A Github PAT"
required: true
runs:
using: "composite"
steps:
- run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/db-ui/core/actions/runs/${{ github.run_id }}/cancel
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
37 changes: 37 additions & 0 deletions .github/actions/download-tar-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: "Download Tar Artifact"
description: "Downloads an artifact and unzips it"
inputs:
name:
description: "Name for artifact"
required: true
path:
description: "Path for unzip"
required: true
runs:
using: "composite"
steps:
- name: ⬇ Download build
uses: actions/download-artifact@v3
with:
name: ${{ inputs.name }}

- name: 📁 Manage path folder
run: |
if [ ! -d ${{ inputs.path }} ]; then
mkdir ${{ inputs.path }}
fi
export amount=1
export path="${{ inputs.path }}"
if [[ "$path" == *\/* ]] || [[ "$path" == *\\* ]]
then
export slashes=$(grep -o "/" <<<"$path" | wc -l)
export amount=$((amount + slashes))
fi
echo "##[set-output name=amount;]$(echo ${amount})"
shell: bash
id: manage-path-folder

- name: 📦 Unpack Tar
run: tar -zxf ${{ inputs.name }} -C ${{ inputs.path }} --strip-components ${{ steps.manage-path-folder.outputs.amount }}
shell: bash
63 changes: 63 additions & 0 deletions .github/scripts/build-gh-page.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

if [[ $NAME == "true" ]]; then
echo "Erro: Missing NAME variable"
exit 1
fi

echo "➕ Create temp or public dir: $NAME"
if [[ $RELEASE == "true" ]]; then
mkdir temp
echo " Created 'temp' dir"
else
mkdir public
echo " Created 'public' dir"
fi


echo "📥 Get gh-pages tar"
curl -L https://github.com/db-ui/core/tarball/gh-pages --output gh-pages

echo "📦 Unpack Tar"
if [[ $RELEASE == "true" ]]; then
tar -zxf gh-pages -C temp --strip-components 1
else
tar -zxf gh-pages -C public --strip-components 1
fi

echo "📁 Bundle public"
if [[ $RELEASE == "true" ]]; then
echo " Move ./out ./public"
mv ./out ./public
cp -R ./public out
if [ -d ./temp/review ]; then
echo " Move ./temp/review ./public"
mv ./temp/review ./public
fi
if [ -d ./temp/version ]; then
echo " Move ./temp/version ./public"
mv ./temp/version ./public
fi
fi

if [[ $PRE_RELEASE == "true" || $RELEASE == "true" ]]; then
if [[ ! -d ./public/version ]]; then
echo " Make dir ./public/version"
mkdir ./public/version
fi
if [[ -d ./public/version/"$NAME" ]]; then
echo " Remove dir ./public/version/$NAME"
rm -rf ./public/version/"$NAME"
fi
mv ./out ./public/version/"$NAME"
else
if [[ ! -d ./public/review ]]; then
echo " Make dir ./public/review"
mkdir ./public/review
fi
if [[ -d ./public/review/"$NAME" ]]; then
echo " Remove dir ./public/review/$NAME"
rm -rf ./public/review/"$NAME"
fi
mv ./out ./public/review/"$NAME"
fi
55 changes: 55 additions & 0 deletions .github/scripts/cleanup-gh-pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Fetches all branches and deletes all review-branches in github pages
*/
const FS = require('fs');

const TAG = 'cleanup-gh-pages:';

const removeOldFromPath = (isTag, data) => {
const path = `public/${isTag ? 'version' : 'review'}`;
if (FS.existsSync(path) && data?.length > 0) {
const dirsToDelete = FS.readdirSync(path).filter(
(file) => !data.find((branch) => branch.name === file)
);
if (dirsToDelete?.length > 0) {
console.log(
TAG,
`Start removing ${isTag ? 'tags' : 'branches'} from gh-pages`
);
console.log(TAG, dirsToDelete);
dirsToDelete.forEach((dir) => {
FS.rmSync(`${path}/${dir}`, {
recursive: true,
force: true
});
console.log(TAG, `deleted ${isTag ? 'tag' : 'branch'} ${dir}`);
});
return true;
} else {
console.log(
TAG,
`All ${isTag ? 'tags' : 'branches'} are up to date`
);
}
}

return false;
};

module.exports = async ({ github, context }) => {
const { repo, owner } = context.repo;
const branches = await github.rest.repos.listBranches({
owner,
repo
});
const tags = await github.rest.repos.listTags({
owner,
repo
});

return {
deploy:
removeOldFromPath(false, branches.data) ||
removeOldFromPath(true, tags.data)
};
};
30 changes: 14 additions & 16 deletions .github/scripts/get-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@

if [[ $GITHUB_REF == refs/tags/v* ]]
then
if [[ $GITHUB_ACTOR != 'dependabot[bot]' ]]
then

if [[ $GITHUB_PRE_RELEASE == true ]]
then
echo "PRE_RELEASE"
elif [[ $GITHUB_COMMITISH == 'main' ]]
then
echo "RELEASE"
fi
else
echo "Dependabot has no permission to publish!"
exit 1
fi
if [[ $GITHUB_ACTOR != 'dependabot[bot]' ]]
then
if [[ $GITHUB_COMMITISH == 'main' && $GITHUB_PRE_RELEASE == false ]]
then
echo "RELEASE"
else
echo "PRE_RELEASE"
fi
else
echo "Dependabot has no permission to publish!"
exit 1
fi
else
echo "Your tag has to start with 'v'"
exit 1
echo "Your tag has to start with 'v'"
exit 1
fi
10 changes: 6 additions & 4 deletions .github/scripts/publish-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ fi
echo "🛠 Forge all packages version numbers"
echo "which package version ?: $VALID_SEMVER_VERSION"

npm version --no-git-tag-version "$VALID_SEMVER_VERSION"
npm version --no-git-tag-version "$VALID_SEMVER_VERSION"

echo "📦 Create packages"
npm pack --quiet
npm pack --quiet

TAG="latest"
if [[ $PRE_RELEASE == 'true' ]]; then
if [[ "$GITHUB_COMMITISH" =~ dbux-[0-9]+ ]];then
TAG=$GITHUB_COMMITISH
elif [[ $PRE_RELEASE == 'true' ]]; then
TAG="next"
fi

echo "📰 Publish Package to Registry with tag: $TAG)"
echo "📰 Publish Package to Registry with tag: $TAG"
for REGISTRY in 'GITHUB' 'NPM'
do
echo "🔒 Authenticate $REGISTRY NPM Registry"
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/00-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.10.1
uses: styfle/cancel-workflow-action@0.11.0

- name: ⬇️ Checkout repo
uses: actions/checkout@v3
Expand All @@ -20,3 +20,9 @@ jobs:
- name: 📥 Download deps default-npm-cache
if: steps.npm-cache.outputs.cache-hit != 'true'
uses: bahmutov/npm-install@v1

- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
if: failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/00-scan-secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Leaked Secrets Scan

on:
workflow_call:

jobs:
TruffleHog:
runs-on: ubuntu-latest
steps:
- name: ⬇ Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: ↔ Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: 🐷 TruffleHog OSS
uses: trufflesecurity/trufflehog@v3.14.0
with:
path: ./
base: ${{ steps.extract_branch.outputs.branch }}
head: HEAD

- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
if: failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}
30 changes: 20 additions & 10 deletions .github/workflows/01-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,26 @@ jobs:
- name: 🍼 Create pages build
run: npm run build

- name: ⬆️Upload page build
uses: actions/upload-artifact@v3
- name: ⬆ Upload dist
uses: ./.github/actions/upload-tar-artifact
with:
name: build
path: public
name: assets
path: dist

- name: ⬆️Upload package build
uses: actions/upload-artifact@v3
- name: ⬆ Upload sources
uses: ./.github/actions/upload-tar-artifact
with:
name: package
path: |
dist/
sources/
name: css-sources
path: sources

- name: ⬆ Upload out
uses: ./.github/actions/upload-tar-artifact
with:
name: patternlab
path: out

- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
if: failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .github/workflows/01-get-publish-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ jobs:
env:
VALID_SEMVER_VERSION: ${{ steps.getVersion.outputs.version }}
run: echo "$VALID_SEMVER_VERSION"

- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
if: failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .github/workflows/01-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ jobs:

- name: ⚡ Run Lint
run: npm run lint

- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
if: failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .github/workflows/01-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ jobs:

- name: ⚡ Run Test
run: npm run test

- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
if: failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}
Loading