-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (82 loc) · 3.83 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Publish Registry
on:
push:
branches: [main, development]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install package dependencies
run: yarn install && yarn compile
- name: Extract branch name
shell: bash
run: echo "current_branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
id: extract_branch
- name: Build the registry locally
run: |
mkdir --parents "${DIST_DIR}/widget-registry"
# Creates the JS & CSS files, and registry.json, and puts them in dist/widget-registry
yarn dlx @js-widgets/webpack-cli \
--debug \
--existing-registry="${PUBLIC_URL}/widget-registry/registry.json" \
--output-dir="${DIST_DIR}/widget-registry" \
.
env:
DEBUG: '*,-babel*,-eslint*'
PUBLIC_URL: https://js-widgets.github.io/registry-starterkit-react/${{ env.current_branch }}
PUBLIC_ASSETS_URL: https://js-widgets.github.io/registry-starterkit-react/${{ env.current_branch }}/static
DIST_DIR: dist/${{ env.current_branch }}
NODE_ENV: production
- name: Prepare public dirs
run: |
# The public files of each widget need to be moved to /static so they are uploaded correctly.
TEMP_DIR=$(mktemp --directory)
mkdir --parents "${TEMP_DIR}/static"
# Find all the folders with the name "public" and copy them to the temporary directory.
while IFS= read -r -d $'\0' directory; do
# From /path/to/src/apps/my-widget/public to ${TEMP_DIR}/static/my-widget
destination=$(echo "${directory}" |sed -e 's:.*/apps/::g' -e 's:/public::g')
cp --recursive "$directory" "$TEMP_DIR/$destination"
done < <(find "./src/apps" -maxdepth 2 -mindepth 1 -type d -name public -print0)
mv "${TEMP_DIR}" "${DIST_DIR}/static"
env:
DIST_DIR: dist/${{ env.current_branch }}
- name: Prepare translations
run: |
# The translations of each widget need to be moved to /translations so they are uploaded correctly.
TEMP_DIR=$(mktemp --directory)
mkdir --parents "${TEMP_DIR}/translations"
# Find all the folders with the name "compiledStrings" and copy them to the temporary directory.
while IFS= read -r -d $'\0' directory; do
# From /path/to/src/apps/my-widget/locales/compiledStrings/es.json to ${TEMP_DIR}/translations/my-widget/es.json
destination=$(echo "${directory}" |sed -e 's:.*/apps/::g' -e 's:/locales/compiledStrings::g')
cp --recursive "$directory" "$TEMP_DIR/$destination"
done < <(find "./src/apps" -type d -name compiledStrings -print0)
mv "${TEMP_DIR}" "${DIST_DIR}/translations"
env:
DIST_DIR: dist/${{ env.current_branch }}
- name: Build the catalog locally
run: |
echo "PUBLIC_ASSETS_URL=/static" > .env.local
yarn storybook:build --output-dir "${DIST_DIR}/storybook"
env:
DEBUG: '*,-babel*,-eslint*'
PUBLIC_URL: https://js-widgets.github.io/registry-starterkit-react/${{ env.current_branch }}/widget-registry
PUBLIC_ASSETS_URL: https://js-widgets.github.io/registry-starterkit-react/${{ env.current_branch }}/static
DIST_DIR: dist/${{ env.current_branch }}
NODE_ENV: production
- name: Deploy to GitHub Pages
if: ${{ success() }}
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: dist
keep_history: true
jekyll: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}