From d7743d149a806e704c636dc712aeb232c019232c Mon Sep 17 00:00:00 2001 From: John Niang Date: Tue, 19 Jul 2022 19:31:11 +0800 Subject: [PATCH] Refactor GitHub workflow configuration (halo-dev/console#589) --- .github/workflows/main.yml | 74 +++++++++++--------------------------- Dockerfile | 19 ++-------- 2 files changed, 22 insertions(+), 71 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28c38e5c6..564947f3d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,12 +2,16 @@ name: Halo Admin CI on: pull_request: + branches: + - next + - main paths: - '**' - '!**.md' push: branches: - - '**' + - next + - main paths: - '**' - '!**.md' @@ -20,32 +24,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - - name: Use Node.js 16 - 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: Environment Set Up + uses: halo-sigs/actions/admin-env-setup@main - name: Install dependencies run: pnpm install - name: Build packages @@ -63,31 +43,8 @@ jobs: if: github.event_name == 'release' steps: - uses: actions/checkout@v3 - - name: Use Node.js 16 - 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: Environment Set Up + uses: halo-sigs/actions/admin-env-setup@main - run: pnpm install - run: pnpm build:packages - name: Build for release @@ -127,5 +84,14 @@ jobs: name: artifactName, 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 diff --git a/Dockerfile b/Dockerfile index 91d9ce70f..d2f8a93ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,4 @@ -# build stage -FROM node:lts-alpine as build-stage -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 +FROM nginx:stable-alpine +COPY ./dist /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]