mirror of https://github.com/halo-dev/halo-admin
Refactor GitHub workflow configuration (#589)
parent
5f8f8c6c29
commit
f29dfc2947
|
@ -2,12 +2,16 @@ name: Halo Admin CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- next
|
||||||
|
- main
|
||||||
paths:
|
paths:
|
||||||
- '**'
|
- '**'
|
||||||
- '!**.md'
|
- '!**.md'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- next
|
||||||
|
- main
|
||||||
paths:
|
paths:
|
||||||
- '**'
|
- '**'
|
||||||
- '!**.md'
|
- '!**.md'
|
||||||
|
@ -20,32 +24,8 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- name: Environment Set Up
|
||||||
- name: Use Node.js 16
|
uses: halo-sigs/actions/admin-env-setup@main
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 16
|
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2.0.1
|
|
||||||
name: Install pnpm
|
|
||||||
id: pnpm-install
|
|
||||||
with:
|
|
||||||
version: 7
|
|
||||||
run_install: false
|
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
|
||||||
id: pnpm-cache
|
|
||||||
run: |
|
|
||||||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
|
||||||
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
name: Setup pnpm cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
|
||||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-pnpm-store-
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
- name: Build packages
|
- name: Build packages
|
||||||
|
@ -63,31 +43,8 @@ jobs:
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Use Node.js 16
|
- name: Environment Set Up
|
||||||
uses: actions/setup-node@v3
|
uses: halo-sigs/actions/admin-env-setup@main
|
||||||
with:
|
|
||||||
node-version: 16
|
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2.0.1
|
|
||||||
name: Install pnpm
|
|
||||||
id: pnpm-install
|
|
||||||
with:
|
|
||||||
version: 7
|
|
||||||
run_install: false
|
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
|
||||||
id: pnpm-cache
|
|
||||||
run: |
|
|
||||||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
|
||||||
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
name: Setup pnpm cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
|
||||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-pnpm-store-
|
|
||||||
|
|
||||||
- run: pnpm install
|
- run: pnpm install
|
||||||
- run: pnpm build:packages
|
- run: pnpm build:packages
|
||||||
- name: Build for release
|
- name: Build for release
|
||||||
|
@ -127,5 +84,14 @@ jobs:
|
||||||
name: artifactName,
|
name: artifactName,
|
||||||
data: await fs.readFile(artifactPathName)
|
data: await fs.readFile(artifactPathName)
|
||||||
});
|
});
|
||||||
|
build-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: check
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Docker build and push
|
||||||
|
uses: halo-sigs/actions/admin-next-docker-build-push@main
|
||||||
|
with:
|
||||||
|
image-name: admin-dev
|
||||||
|
ghcr-token: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
push: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/next' }} # we only push to GHCR if the push is to the next branch
|
||||||
|
|
19
Dockerfile
19
Dockerfile
|
@ -1,19 +1,4 @@
|
||||||
# build stage
|
FROM nginx:stable-alpine
|
||||||
FROM node:lts-alpine as build-stage
|
COPY ./dist /usr/share/nginx/html
|
||||||
ENV PNPM_VERSION 7.5.0
|
|
||||||
RUN apk --no-cache add curl
|
|
||||||
RUN curl -sL https://unpkg.com/@pnpm/self-installer | node
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
COPY . .
|
|
||||||
RUN pnpm install
|
|
||||||
RUN pnpm build:packages
|
|
||||||
RUN pnpm build
|
|
||||||
RUN pnpm store prune
|
|
||||||
RUN rm -rf ~/.pnpm-store
|
|
||||||
|
|
||||||
# production stage
|
|
||||||
FROM nginx:stable-alpine as production-stage
|
|
||||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|
Loading…
Reference in New Issue