[sc-11330] Fix input type number (#1942) #1972
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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
env: | |
APP_IMAGE_NAME: app | |
MANAGER_IMAGE_NAME: manager | |
CDN_STORAGE: ${{ github.ref == 'refs/heads/main' && secrets.CDN_STORAGE || secrets.CDN_STORAGE_DEV }} | |
DOCS_STORAGE: ${{ github.ref == 'refs/heads/main' && secrets.DOCS_STORAGE || secrets.DOCS_STORAGE_DEV }} | |
GCP_WORKLOAD_IDENTITY_PROVIDER: 'projects/224545243904/locations/global/workloadIdentityPools/gh-nuclia/providers/gh-nuclia-provider' | |
GCP_SERVICE_ACCOUNT: '[email protected]' | |
DEPLOYMENT_ENVIRONMENT: ${{ github.ref == 'refs/heads/main' && 'stage' || 'dev' }} | |
PROMO_PRODUCTION: false | |
permissions: | |
id-token: write | |
contents: write | |
jobs: | |
build: | |
runs-on: nuclia-base | |
outputs: | |
deploy-widget: ${{ steps.check-deploy.outputs.deploy-widget }} | |
deploy-app: ${{ steps.check-deploy.outputs.deploy-app }} | |
deploy-nucliadb-admin: ${{ steps.check-deploy.outputs.deploy-nucliadb-admin }} | |
deploy-manager: ${{ steps.check-deploy.outputs.deploy-manager }} | |
deploy-sistema: ${{ steps.check-deploy.outputs.deploy-sistema }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Authenticate to Google Cloud | |
id: gcp-auth | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: '${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}' | |
service_account: '${{ env.GCP_SERVICE_ACCOUNT }}' | |
token_format: access_token | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
- name: Login to Google Artifact Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: europe-west4-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.gcp-auth.outputs.access_token }} | |
- uses: nrwl/nx-set-shas@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: 'yarn' | |
- name: Calculate short sha | |
run: echo "SHORT_SHA=`echo hash${GITHUB_SHA} | cut -c1-12`" >> $GITHUB_ENV | |
- name: Install project dependencies | |
run: |- | |
yarn | |
yarn missdev | |
- name: Unit tests | |
run: npx nx affected --target=test --parallel=3 --exclude=sdk-demo,search-widget-demo,core,sistema-demo | |
- name: Build affected apps | |
run: npx nx affected --target=build --parallel=3 --configuration production --exclude=sdk-demo,search-widget-demo | |
- name: Get package version | |
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV | |
- name: Tag if new version | |
uses: pkgdeps/[email protected] | |
if: github.ref == 'refs/heads/main' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
github_repo: ${{ github.repository }} | |
version: ${{ env.PACKAGE_VERSION }} | |
git_commit_sha: ${{ github.sha }} | |
git_tag_prefix: 'v' | |
- name: Check apps to deploy | |
id: check-deploy | |
run: |- | |
(test -d dist/libs/search-widget && echo "deploy-widget=yes" >> $GITHUB_OUTPUT) || echo "Widget unchanged" | |
(test -d dist/apps/dashboard && echo "deploy-app=yes" >> $GITHUB_OUTPUT) || echo "Dashboard unchanged" | |
(test -d dist/apps/nucliadb-admin && echo "deploy-nucliadb-admin=yes" >> $GITHUB_OUTPUT) || echo "NucliaDB admin unchanged" | |
(test -d dist/apps/manager-v2 && echo "deploy-manager=yes" >> $GITHUB_OUTPUT) || echo "Manager unchanged" | |
(test -d dist/apps/sistema-demo && echo "deploy-sistema=yes" >> $GITHUB_OUTPUT) || echo "Sistema demo unchanged" | |
(test -d dist/sdk-core && echo "deploy-sdk=yes" >> $GITHUB_OUTPUT) || echo "SDK unchanged" | |
- name: Publish widget | |
if: steps.check-deploy.outputs.deploy-widget == 'yes' | |
run: |- | |
find dist/libs/search-widget -type f -name *.umd.js -exec sed -i.bak "s,__NUCLIA_DEV_VERSION__,$GITHUB_SHA,g" {} \; | |
gsutil copy dist/libs/search-widget/*.umd.js gs://$CDN_STORAGE | |
gsutil copy dist/libs/search-widget/*.css gs://$CDN_STORAGE | |
gsutil copy -r libs/search-widget/public/* gs://$CDN_STORAGE | |
- name: Publish SDK | |
if: steps.check-deploy.outputs.deploy-sdk == 'yes' && github.ref == 'refs/heads/main' | |
uses: JS-DevTools/npm-publish@v1 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
package: ./dist/sdk-core/package.json | |
- name: Generate and push SDK docs | |
if: steps.check-deploy.outputs.deploy-sdk == 'yes' && github.ref == 'refs/heads/main' | |
run: |- | |
sh ./tools/build-sdk-docs.sh | |
gsutil -m rsync -r ./libs/sdk-core/docs gs://$DOCS_STORAGE/js-sdk | |
- name: Generate a token | |
id: app-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.GHAPP_ID_NUCLIABOT }} | |
private-key: ${{ secrets.PK_GHAPP_NUCLIABOT }} | |
owner: nuclia | |
- name: Checkout tooling repository | |
uses: actions/checkout@v4 | |
with: | |
repository: nuclia/tooling | |
ref: main | |
path: tooling | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Push image to registries | |
uses: ./tooling/.github/actions/build-img-regcache | |
if: steps.check-deploy.outputs.deploy-app == 'yes' | |
with: | |
build-arg: | | |
appId=app | |
appFolder=dashboard | |
noRelativeCss=true | |
file: docker/Dockerfile | |
image-name: ${{ env.APP_IMAGE_NAME }} | |
image-version: ${{ env.SHORT_SHA }} | |
skip-ecr-push: true | |
push: true | |
tag-latest: main | |
- name: Publish NucliaDB admin app | |
if: steps.check-deploy.outputs.deploy-nucliadb-admin == 'yes' && github.ref == 'refs/heads/main' | |
run: |- | |
sed -i.bak "s,STF_DOCKER_CONFIG_VERSION,$GITHUB_SHA,g" dist/apps/nucliadb-admin/assets/deployment/app-config.json | |
cp -r dist/apps/nucliadb-admin/* tools/python-nucliadb-admin-dist/nucliadb_admin_assets/ | |
make -C tools/python-nucliadb-admin-dist/ publish ARGS="--build=${{github.run_number}}" | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
- name: Push image to registries | |
uses: ./tooling/.github/actions/build-img-regcache | |
if: steps.check-deploy.outputs.deploy-manager == 'yes' | |
with: | |
build-arg: | | |
appId=manager | |
appFolder=manager-v2 | |
noRelativeCss=true | |
file: docker/Dockerfile | |
image-name: ${{ env.MANAGER_IMAGE_NAME }} | |
image-version: ${{ env.SHORT_SHA }} | |
skip-ecr-push: true | |
skip-context-creation: true | |
push: true | |
tag-latest: main | |
- name: Create 404 page for gh-pages | |
if: steps.check-deploy.outputs.deploy-sistema == 'yes' && github.ref == 'refs/heads/main' | |
run: |- | |
cp dist/apps/sistema-demo/index.html dist/apps/sistema-demo/404.html | |
- name: Deploy sistema-demo to GH pages | |
if: steps.check-deploy.outputs.deploy-sistema == 'yes' && github.ref == 'refs/heads/main' | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: dist/apps/sistema-demo | |
- name: Upload sourcemaps to Sentry | |
uses: getsentry/[email protected] | |
if: github.ref == 'refs/heads/main' | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: nuclia | |
SENTRY_PROJECT: application | |
deploy-app: | |
name: Deploy dashboard | |
runs-on: ubuntu-latest | |
needs: build | |
if: needs.build.outputs.deploy-app == 'yes' | |
outputs: | |
json-summary: | | |
{ | |
"components": [ | |
{ | |
"component": "app", | |
"chart-version": "${{ steps.chart-version-app.outputs.chart-version }}", | |
"component-type": "global" | |
} | |
] | |
} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Authenticate to Google Cloud | |
id: gcp-auth | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: "${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}" | |
service_account: "${{ env.GCP_SERVICE_ACCOUNT }}" | |
token_format: access_token | |
- name: Login to Google Artifact Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: europe-west4-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.gcp-auth.outputs.access_token }} | |
- name: Calculate short sha | |
run: echo "SHORT_SHA=`echo hash${GITHUB_SHA} | cut -c1-12`" >> $GITHUB_ENV | |
- name: Generate a token | |
id: app-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.GHAPP_ID_NUCLIABOT }} | |
private-key: ${{ secrets.PK_GHAPP_NUCLIABOT }} | |
owner: nuclia | |
- name: Checkout tooling repository | |
uses: actions/checkout@v4 | |
with: | |
repository: nuclia/tooling | |
ref: main | |
path: tooling | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Get chart version | |
id: chart-version-app | |
run: | | |
VERSION=`cat apps/dashboard/VERSION` | |
echo "chart-version=$VERSION-${{ env.SHORT_SHA }}" >> $GITHUB_OUTPUT | |
- name: Build and push helm chart | |
uses: ./tooling/.github/actions/build-helm-chart | |
with: | |
component: ${{ env.APP_IMAGE_NAME }} | |
chart-version: ${{ steps.chart-version-app.outputs.chart-version }} | |
image-name: ${{ env.APP_IMAGE_NAME }} | |
image-version: ${{ env.SHORT_SHA }} | |
hash: ${{ env.SHORT_SHA }} | |
helm-chart-url: ${{ secrets.HELM_CHART_URL }} | |
chart-dir: "./charts/${{ env.APP_IMAGE_NAME }}" | |
helm-version: v3.15.3 | |
push-to-artifact-registry: true | |
deploy-manager: | |
name: Deploy manager | |
runs-on: ubuntu-latest | |
needs: build | |
if: needs.build.outputs.deploy-manager == 'yes' | |
outputs: | |
json-summary: | | |
{ | |
"components": [ | |
{ | |
"component": "manager", | |
"chart-version": "${{ steps.chart-version-manager.outputs.chart-version }}", | |
"component-type": "global" | |
} | |
] | |
} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Authenticate to Google Cloud | |
id: gcp-auth | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: "${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}" | |
service_account: "${{ env.GCP_SERVICE_ACCOUNT }}" | |
token_format: access_token | |
- name: Login to Google Artifact Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: europe-west4-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.gcp-auth.outputs.access_token }} | |
- name: Calculate short sha | |
run: echo "SHORT_SHA=`echo hash${GITHUB_SHA} | cut -c1-12`" >> $GITHUB_ENV | |
- name: Generate a token | |
id: app-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.GHAPP_ID_NUCLIABOT }} | |
private-key: ${{ secrets.PK_GHAPP_NUCLIABOT }} | |
owner: nuclia | |
- name: Checkout tooling repository | |
uses: actions/checkout@v4 | |
with: | |
repository: nuclia/tooling | |
ref: main | |
path: tooling | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Get chart version | |
id: chart-version-manager | |
run: | | |
VERSION=`cat apps/manager-v2/VERSION` | |
echo "chart-version=$VERSION-${{ env.SHORT_SHA }}" >> $GITHUB_OUTPUT | |
- name: Build and push helm chart | |
uses: ./tooling/.github/actions/build-helm-chart | |
with: | |
component: ${{ env.MANAGER_IMAGE_NAME }} | |
chart-version: ${{ steps.chart-version-manager.outputs.chart-version }} | |
image-name: ${{ env.MANAGER_IMAGE_NAME }} | |
image-version: ${{ env.SHORT_SHA }} | |
hash: ${{ env.SHORT_SHA }} | |
helm-chart-url: ${{ secrets.HELM_CHART_URL }} | |
chart-dir: "./charts/${{ env.MANAGER_IMAGE_NAME }}" | |
helm-version: v3.15.3 | |
push-to-artifact-registry: true | |
send-to-promotion: | |
runs-on: ubuntu-latest | |
needs: [deploy-manager, deploy-app] | |
if: | | |
!failure() && !cancelled() && github.event_name == 'push' && | |
( needs.deploy-manager.result != 'skipped' || | |
needs.deploy-app.result != 'skipped' ) | |
steps: | |
- name: Generate a token | |
id: app-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.GHAPP_ID_NUCLIABOT }} | |
private-key: ${{ secrets.PK_GHAPP_NUCLIABOT }} | |
owner: nuclia | |
- name: Create components promotion summary. Trigger1 | |
env: | |
SKIP_QUEUE: ${{ contains(github.event.pull_request.labels.*.name, 'skip-promo-queue') }} | |
SKIP_ARGO_HEALTH: false | |
ENVIRONMENT: ${{ github.ref == 'refs/heads/main' && 'stage' || 'dev' }} | |
PROMO_PRODUCTION: ${{ env.PROMO_PRODUCTION }} | |
TEAM: ${{ secrets.TEAM_NAME }} | |
SLACK_TEAM: ${{ secrets.SLACK_TEAM }} | |
run: | | |
MERGED_JSON=$(jq -cs \ | |
--arg environment "$ENVIRONMENT" \ | |
--arg skip_queue "$SKIP_QUEUE" \ | |
--arg promo_production "$PROMO_PRODUCTION" \ | |
--arg team "$TEAM" \ | |
--arg slack_team "$SLACK_TEAM" \ | |
--arg skip_argo_health "$SKIP_ARGO_HEALTH" \ | |
--arg commit_sha "${{ github.sha }}" \ | |
'{ | |
components: map(.components) | add | |
} + { | |
skip_promo_queue: ($skip_queue == "true") | |
} + { | |
skip_argo_health: ($skip_argo_health == "true") | |
} + { | |
environment: $environment | |
} + { | |
promo_production: ($promo_production == "true") | |
} + { | |
team: $team | |
} + { | |
slack_team: $slack_team | |
} + { | |
tests: { | |
"run-e2e": true, | |
"run-nuclia-e2e": false | |
} | |
} + { | |
"commit-sha": $commit_sha | |
}' \ | |
<(echo '${{ needs.deploy-manager.outputs.json-summary }}') \ | |
<(echo '${{ needs.deploy-app.outputs.json-summary }}') | |
) | |
echo "JSON_PROMO_SUMMARY=$MERGED_JSON" >> $GITHUB_ENV | |
- name: Send to promotion queue | |
id: send-to-promo | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
repository: nuclia/core-apps | |
event-type: promotions | |
client-payload: '${{ env.JSON_PROMO_SUMMARY }}' |