Skip to content

Commit

Permalink
ci: upgrade to GHA (#1747)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Dec 31, 2023
1 parent 7e61fc2 commit fc1954e
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 168 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: CI

on: push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jwalton/gh-find-current-pr@v1
id: findPr
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Comment on github
run: node ./scripts/github/comment.js "[Preview Preparing...](https://github.com/ng-alain/delon/actions/runs/${{ github.run_id }})"
env:
ACCESS_REPO: ${{ github.repository }}
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
PR_NUMBER: ${{ steps.findPr.outputs.pr }}
- uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/*.patch') }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Build artifacts
run: ./scripts/ci/build-artifacts.sh
env:
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
- name: Build site
run: yarn run site:build
- name: 'Deploy Site'
run: |
export DEPLOY_DOMAIN=https://preview-${{ steps.findPr.outputs.pr }}-ng-alain-delon.surge.sh
echo "Deploy to $DEPLOY_DOMAIN"
cp ./src/dist/browser/index.html ./src/dist/browser/404.html
npx surge --project ./src/dist/browser --domain $DEPLOY_DOMAIN
env:
ACCESS_REPO: ${{ github.repository }}
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
- name: 'Update comment on github'
run: |
export DEPLOY_DOMAIN=https://preview-${{ steps.findPr.outputs.pr }}-ng-alain-delon.surge.sh
node ./scripts/github/comment.js "[Preview is ready!]($DEPLOY_DOMAIN)"
env:
ACCESS_REPO: ${{ github.repository }}
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
PR_NUMBER: ${{ steps.findPr.outputs.pr }}
- name: 'When failed'
if: failure()
run: node ./scripts/github/comment.js "[Preview Build Failed!](https://github.com/ng-alain/delon/actions/runs/${{ github.run_id }})"
env:
ACCESS_REPO: ${{ github.repository }}
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
PR_NUMBER: ${{ steps.findPr.outputs.pr }}

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/*.patch') }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Test
run: yarn run test
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/
files: cobertura-coverage.xml
fail_ci_if_error: true
verbose: true

test-cli:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/*.patch') }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Test
run: yarn run test:cli

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/*.patch') }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Check code lint
run: yarn run lint
150 changes: 0 additions & 150 deletions azure-pipelines.yml

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/azure/github-comment.js → scripts/github/comment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const REPO = process.env.ACCESS_REPO;
const TOKEN = process.env.ACCESS_TOKEN;
const PR = process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER;
const REPLACE_MARK = '<!-- AZURE_UPDATE_COMMENT -->';
const PR = process.env.PR_NUMBER;
const REPLACE_MARK = '<!-- GHA_UPDATE_COMMENT -->';

const argv = process.argv;

Expand Down
4 changes: 2 additions & 2 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { provideHttpClient, withFetch, withInterceptors } from '@angular/common/
import ngLang from '@angular/common/locales/zh';
import { APP_ID, ApplicationConfig, ErrorHandler, importProvidersFrom } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideRouter, withComponentInputBinding } from '@angular/router';
import { provideRouter, withComponentInputBinding, withInMemoryScrolling } from '@angular/router';
import { ServiceWorkerModule } from '@angular/service-worker';

import { provideNuMonacoEditorConfig } from '@ng-util/monaco-editor';
Expand Down Expand Up @@ -92,7 +92,7 @@ export const appConfig: ApplicationConfig = {
{ provide: APP_ID, useValue: 'ngAlainDoc' },
provideHttpClient(withFetch(), withInterceptors([mockInterceptor])),
provideAnimations(),
provideRouter(routes, withComponentInputBinding()),
provideRouter(routes, withComponentInputBinding(), withInMemoryScrolling({ scrollPositionRestoration: 'top' })),
// provideClientHydration(), // 暂时不开启水合,除了编译时间长,还有就是对DOM要求比较高
provideAlain({ config: alainConfig, defaultLang, i18nClass: I18NService }),
provideNzConfig(ngZorroConfig),
Expand Down
22 changes: 10 additions & 12 deletions src/app/layout/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,16 @@
}
<div nz-row style="flex-flow: nowrap; height: 64px">
<div nz-col nzXs="24" nzSm="24" nzMd="24" nzLg="24" nzXl="5" nzXXl="4">
<h1>
<a
routerLink="/{{ i18n.zone }}"
nz-tooltip
nzTooltipTitle="{{ 'app.footer.qqgroup' | i18n }}: 316911865"
(click)="onCopy('316911865')"
id="logo"
>
<img src="./assets/img/logo-color.svg" style="max-height: 32px" />
NG-ALAIN
</a>
</h1>
<a
routerLink="/{{ i18n.zone }}"
nz-tooltip
nzTooltipTitle="{{ 'app.footer.qqgroup' | i18n }}: 316911865"
(click)="onCopy('316911865')"
id="logo"
>
<img src="./assets/img/logo-color.svg" alt="NG-ALAIN Logo" title="NG-ALAIN Logo" style="max-height: 32px" />
NG-ALAIN
</a>
</div>
<div nz-col nz-col nzXs="0" nzSm="0" nzMd="0" nzLg="0" nzXl="19" nzXXl="20" class="menu-row">
<header-search />
Expand Down
12 changes: 10 additions & 2 deletions src/app/routes/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ <h1 data-aos="fade-up" data-aos-once="true">NG-ALAIN</h1>
@for (i of allThemes; track $index) {
<div nz-carousel-content>
<a [attr.href]="i.url" target="_blank">
<img src="./assets/screenshot/{{ i.screenshot }}" />
<img
src="./assets/screenshot/{{ i.screenshot }}"
[attr.alt]="'app.home.theme.' + i.type | i18n"
[attr.title]="'app.home.theme.' + i.type | i18n"
/>
</a>
</div>
}
Expand Down Expand Up @@ -127,7 +131,11 @@ <h2>{{ 'app.home.theme' | i18n }}</h2>
data-aos-delay="0"
[attr.data-theme]="t"
>
<img src="./assets/screenshot/{{ t.screenshot }}" />
<img
src="./assets/screenshot/{{ t.screenshot }}"
[attr.alt]="'app.home.theme.' + t.type | i18n"
[attr.title]="'app.home.theme.' + t.type | i18n"
/>
<h3>{{ 'app.home.theme.' + t.type | i18n }}</h3>
<p>{{ 'app.home.theme.' + t.type + '.desc' | i18n }}</p>
</a>
Expand Down

0 comments on commit fc1954e

Please sign in to comment.