feat: add esm in node runtime #152
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: ["**"] | |
| workflow_dispatch: | |
| inputs: | |
| version_name: | |
| description: "手动发布的版本标签,例如 v1.0.0" | |
| required: false | |
| type: string | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Install pnpm | |
| run: npm install -g pnpm@latest-10 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25.x' | |
| # - name: Build Backend Project | |
| # run: | | |
| # chmod +x ./build.sh | |
| # ./build.sh | |
| - name: Prepare image tags | |
| env: | |
| IMAGE_REPO: ${{ vars.IMAGE_REPO }} | |
| EVENT_NAME: ${{ github.event_name }} | |
| REF_NAME: ${{ github.ref_name }} | |
| VERSION_NAME: ${{ github.event.inputs.version_name }} | |
| run: | | |
| SHORT_SHA=${GITHUB_SHA::7} | |
| VERSION_NAME="$(echo "${VERSION_NAME}" | xargs)" | |
| TAGS="${IMAGE_REPO}:${SHORT_SHA}" | |
| if [ "${EVENT_NAME}" = "push" ] && [ "${REF_NAME}" = "main" ]; then | |
| TAGS="${TAGS}"$'\n'"${IMAGE_REPO}:latest" | |
| elif [ "${EVENT_NAME}" = "push" ]; then | |
| TAGS="${TAGS}"$'\n'"${IMAGE_REPO}:test" | |
| fi | |
| if [ "${EVENT_NAME}" = "workflow_dispatch" ] && [ -n "${VERSION_NAME}" ]; then | |
| TAGS="${TAGS}"$'\n'"${IMAGE_REPO}:${VERSION_NAME}" | |
| fi | |
| echo "IMAGE_TAGS<<EOF" >> "$GITHUB_ENV" | |
| printf '%s\n' "${TAGS}" >> "$GITHUB_ENV" | |
| echo "EOF" >> "$GITHUB_ENV" | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push Docker image | |
| env: | |
| IMAGE_TAGS: ${{ env.IMAGE_TAGS }} | |
| run: | | |
| TAG_ARGS=() | |
| while IFS= read -r tag; do | |
| if [ -n "${tag}" ]; then | |
| TAG_ARGS+=(-t "${tag}") | |
| fi | |
| done <<< "${IMAGE_TAGS}" | |
| docker build "${TAG_ARGS[@]}" -f "./Dockerfile.prod" . | |
| while IFS= read -r tag; do | |
| if [ -n "${tag}" ]; then | |
| docker push "${tag}" | |
| fi | |
| done <<< "${IMAGE_TAGS}" |