From b49f6f8a279771af3b80a3e5a403047aa2b80f44 Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+KrickRay@users.noreply.github.com> Date: Mon, 17 Jan 2022 11:20:10 +0300 Subject: [PATCH] TECHDEBT-36: Add CI check and build (#9) --- .github/actions/init/action.yaml | 18 +++++++++++++++ .github/workflows/build-push.yaml | 33 +++++++++++++++++++++++++++ .github/workflows/pr-build-check.yaml | 22 ++++++++++++++++++ .github/workflows/pr.yaml | 18 +++++++-------- .idea/prettier.xml | 2 +- .prettierignore | 4 +++- Dockerfile | 3 +++ package.json | 10 ++++---- 8 files changed, 94 insertions(+), 16 deletions(-) create mode 100644 .github/actions/init/action.yaml create mode 100644 .github/workflows/build-push.yaml create mode 100644 .github/workflows/pr-build-check.yaml create mode 100644 Dockerfile diff --git a/.github/actions/init/action.yaml b/.github/actions/init/action.yaml new file mode 100644 index 00000000..687c1ac9 --- /dev/null +++ b/.github/actions/init/action.yaml @@ -0,0 +1,18 @@ +name: Init +description: Init +runs: + using: composite + steps: + - name: Init NodeJS + uses: actions/setup-node@v2 + with: + node-version: '16.13.2' + cache: 'npm' + + - name: Install Packages + run: npm ci + shell: bash + + - name: Generate Swagger & OpenAPI code + run: npm run codegen + shell: bash diff --git a/.github/workflows/build-push.yaml b/.github/workflows/build-push.yaml new file mode 100644 index 00000000..01a04138 --- /dev/null +++ b/.github/workflows/build-push.yaml @@ -0,0 +1,33 @@ +name: Build & Push +on: + push: + branches: + - 'master' + - 'main' +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Init + uses: ./.github/actions/init + + - name: Check & Build + run: npm run ci:build + + - name: Deploy image + uses: valitydev/action-deploy-docker@v1.0.16 + with: + registry-username: ${{ github.actor }} + registry-access-token: ${{ secrets.GITHUB_TOKEN }} + dockerfile-path: . + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} diff --git a/.github/workflows/pr-build-check.yaml b/.github/workflows/pr-build-check.yaml new file mode 100644 index 00000000..6f4e7590 --- /dev/null +++ b/.github/workflows/pr-build-check.yaml @@ -0,0 +1,22 @@ +name: 'PR: Build & Check' +on: + pull_request: + branches: ['*'] +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Init + uses: ./.github/actions/init + + - name: Check & Build + run: npm run ci:build diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 5fb130b0..2a443655 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -1,13 +1,13 @@ name: 'PR Title Checker' on: - pull_request: - types: [edited, opened, synchronize, reopened] - branches: [disabled] + pull_request: + types: [edited, opened, synchronize, reopened] + branches: [disabled] jobs: - title-check: - runs-on: ubuntu-latest - steps: - - uses: naveenk1223/action-pr-title@master - with: - regex: '([A-Z]+-[0-9]+,?)+: [A-Z0-9].*' + title-check: + runs-on: ubuntu-latest + steps: + - uses: naveenk1223/action-pr-title@master + with: + regex: '([A-Z]+-[0-9]+,?)+: [A-Z0-9].*' diff --git a/.idea/prettier.xml b/.idea/prettier.xml index 4f3d2bde..8840ae82 100644 --- a/.idea/prettier.xml +++ b/.idea/prettier.xml @@ -3,6 +3,6 @@ \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 35a0e8fd..6fa86535 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,4 +8,6 @@ src/app/**/swagger-codegen src/app/**/openapi-codegen src/app/**/gen-model .vscode -.swagger-codegen \ No newline at end of file +.idea +.swagger-codegen +.angular \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c5b31212 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:1.21 +COPY dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/vhosts.d/dashboard.conf \ No newline at end of file diff --git a/package.json b/package.json index 4fd04e60..4979996a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "dashboard", "version": "0.0.0", + "private": true, "scripts": { "postinstall": "ngcc", "start": "ng serve --port 8000", @@ -14,20 +15,19 @@ "lint": "npm run lint-cache-cmd", "lint-fix": "npm run lint-cache-cmd -- --fix", "lint-errors": "npm run lint-cache-cmd -- --quiet", - "prettier-cmd": "prettier \"**/*.{html,js,ts,css,scss,md,json,prettierrc,svg}\"", + "prettier-cmd": "prettier \"**/*.{html,js,ts,css,scss,md,json,prettierrc,svg,yaml,yml}\"", "prettier": "npm run prettier-cmd -- --check", "prettier-fix": "npm run prettier-cmd -- --write", "tools-cmd": "ts-node --project tools/tsconfig.json", - "parallel-cmd": "concurrently --prefix-colors magenta,green", + "parallel-cmd": "concurrently --kill-others-on-fail --prefix-colors magenta,green,red,yellow,blue", "swagger-codegen": "npm run tools-cmd -- tools/swagger-codegen.ts", "openapi-codegen": "openapi-generator-cli version && npm run tools-cmd -- tools/openapi-codegen.ts", "codegen": "npm run parallel-cmd -- --names SWAG,OAPI \"npm run swagger-codegen\" \"npm run openapi-codegen\"", "icons-list-gen": "npm run tools-cmd -- tools/gen-icons-list.ts", "icons-ids-gen": "npm run tools-cmd -- tools/gen-icons-ids.ts", - "ci:check": "npm run parallel-cmd -- --names PRET,LINT \"npm run prettier\" \"npm run lint-cmd -- --quiet\"", - "ci:test": "npm run test -- --configuration=ci" + "ci:test": "npm run test -- --configuration=ci", + "ci:build": "npm run parallel-cmd -- --names PRETTIER,LINT,BUILD \"npm run prettier\" \"npm run lint-cmd -- --quiet\" \"npm run build\"" }, - "private": true, "dependencies": { "@angular/animations": "~13.1.1", "@angular/cdk": "~13.1.1",