Skip to content

Commit

Permalink
UPDATE: Github Actions publish and release
Browse files Browse the repository at this point in the history
  • Loading branch information
kainonly committed Jan 10, 2023
1 parent b58a0ac commit 1e37ac2
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 5 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish NPM Package

on:
push:
tags:
- ng-*

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: 检出
uses: actions/checkout@v3

- name: 安装 Node
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: https://registry.npmjs.org
cache: 'npm'

- name: 安装依赖
run: npm ci

- name: 构建 Angular 库
run: |
npm run build:ng
- name: 发布至 NPM
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: |
cd ./dist/angular
npm version ${{github.ref_name}}
npm publish --access=public
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release Console Container

on:
push:
tags:
- v*

env:
REGISTRY: ghcr.io
TCR_REGISTRY: ccr.ccs.tencentyun.com
IMAGE_NAME: ${{ github.repository }}

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: https://registry.npmjs.org
cache: 'npm'

- run: npm ci
- run: npm run build:ssr

- name: Login GitHub Container Hub
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login TCR
uses: docker/login-action@v1
with:
registry: ${{ env.TCR_REGISTRY }}
username: ${{ secrets.TCR_USERNAME }}
password: ${{ secrets.TCR_PASSWORD }}

- name: Get Metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Copy to QCLOUD TCR
uses: akhilerm/[email protected]
with:
src: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{steps.meta.outputs.version}}
dst: |
${{ env.TCR_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.TCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{steps.meta.outputs.version}}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:18-alpine

COPY dist /app/dist
WORKDIR /app

EXPOSE 4200

CMD [ "node", "dist/console/server/main.js" ]
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
"scripts": {
"start": "ng s",
"start:proxy": "ng s --proxy-config src/proxy.conf.json",
"serve:ssr": "node dist/console/server/main.js",
"build": "ng b --configuration production",
"build:ssr": "npm run build && ng run console:server",
"build:ng": "ng b angular --configuration production",
"prerender": "ng run console:prerender",
"test": "ng t angular --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessCI",
"lint": "ng lint",
"e2e": "ng e2e",
"dev:ssr": "ng run console:serve-ssr",
"serve:ssr": "node dist/console/server/main.js",
"build:ssr": "npm run build && ng run console:server",
"prerender": "ng run console:prerender"
"e2e": "ng e2e"
},
"dependencies": {
"@angular/animations": "^15.0.4",
Expand Down

0 comments on commit 1e37ac2

Please sign in to comment.