Skip to content

Node.js CI

Node.js CI #5

Workflow file for this run

name: Node.js CI
on:
push:
branches:
- mirrorz
pull_request:
branches:
- mirrorz
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- name: node_modules CI Cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/mirrorz-help/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
- name: Next.js CI Cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/mirrorz-help/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('src/**', 'contents/**') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Override
run: |
cp .env.local mirrorz-help/.env.local
cp override/routes.json mirrorz-help/src/routes.json
cp override/contents/*.mdx mirrorz-help/contents/ || :
- name: Build
run: |
cd mirrorz-help
npm ci
npm run og:build
npm run build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/cquptmirror/mirrorz-help:latest
cquptmirror/mirrorz-help:latest