Skip to content

Commit

Permalink
chore: fix for docker-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Feb 19, 2024
1 parent 6b950c5 commit 01eecda
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 135 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/docker-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: deploy to docker hub

on:
push:
tags:
- "v*.*.*"
branches:
- 'master'

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ${{ secrets.REGISTRY }}
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
docker-deploy:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
# -
# name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# -
# name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# 提供 docker 元数据,构建 docker images tag 时使用
-
name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# tag event
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
# registry: ghcr.io # 声明镜像源
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
# platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# -
# name: Login to Docker Hub
# run: |
# docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }} ${{ env.REGISTRY }}
# -
# name: Build and push Docker Image
# run: |
# docker build -t ${{ env.REGISTRY }}/${{ steps.meta.outputs.tags }} -f Dockerfile .
# docker push ${{ env.REGISTRY }}/${{ steps.meta.outputs.tags }}

# -
# name: Deploy Docker App
# uses: appleboy/ssh-action@master
# env:
# TZ: Asia/Shanghai
# with:
# host: ${{ secrets.HOST }}
# username: ${{ secrets.HOST_USERNAME }}
# key: ${{ secrets.HOST_SSHKEY }}
# port: ${{ secrets.PORT }}
# script: |
# wget https://raw.githubusercontent.com/${{ env.IMAGE_NAME }}/master/docker/docker-compose.yml
# ls
# cat docker-compose.yml
# docker-compose down -v
# docker-compose up -d
85 changes: 85 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Publish to NPM

on:
push:
tags:
- "v*.*.*"
# release:
# types: [created]

jobs:
npm-publish:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
-
name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.com
-
name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false
-
name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
-
name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
-
name: Install dependencies
run: pnpm install --no-frozen-lockfile --ignore-scripts

# - name: Build and npm-publish
# run: npm run release

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

# run: npm run publish:github # --registry=https://npm.pkg.github.com
# env:
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

# - name: GitHub Pages action
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./docs
-
name: Github Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
prerelease: false
# tag_name: ${{ github.ref }}
# name: Release ${{ github.ref }}
# body: TODO New Release.
# files: |
# ${{ secrets.ReleaseZipName }}.zip
# LICENSE

134 changes: 0 additions & 134 deletions .github/workflows/release.yml

This file was deleted.

3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ COPY codes codes
COPY lib lib
COPY package.json .
COPY index.js .
COPY eng.traineddata .
# COPY eng.traineddata .
ADD https://github.com/tesseract-ocr/tessdata/raw/main/eng.traineddata .

ENV NODE_PATH /usr/local/lib/node_modules
ENV NODE_ENV production
Expand Down

0 comments on commit 01eecda

Please sign in to comment.