main
This commit is contained in:
parent
de8761846a
commit
e65a2ded46
@ -1,5 +1,5 @@
|
|||||||
name: CI
|
name: Build docker and publish
|
||||||
|
run-name: The pipeline for docker build
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@ -9,52 +9,66 @@ on:
|
|||||||
- cicd
|
- cicd
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
# Docker
|
||||||
REPO: ${{ vars.REPO }}
|
REPO: ${{ vars.REPO }}
|
||||||
|
# Gitea
|
||||||
|
GIT_USERNAME: ${{ vars.GIT_USERNAME }}
|
||||||
|
GIT_PASSWORD: ${{ vars.GIT_PASSWORD }}
|
||||||
|
# Host SSH
|
||||||
|
SSH_HOST: ${{ vars.SSH_HOST }}
|
||||||
|
SSH_PORT: ${{ vars.SSH_PORT }}
|
||||||
|
SSH_USER: ${{ vars.SSH_USER }}
|
||||||
|
SSH_PASSWORD: ${{ vars.SSH_PASSWORD }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
linux:
|
||||||
runs-on: ppanel-web
|
runs-on: ppanel-web
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# 只有node支持版本号别名
|
# 使用gitea-tool-cache需要指定具体的版本号
|
||||||
node: ['20.15.1']
|
go: ["1.24.3"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout
|
||||||
uses: https://shanshanzhong147@gmail.com:shanshanzhong147@git.kxsw.us/actions/checkout
|
uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/checkout@main
|
||||||
|
|
||||||
- name: change npm registry mirror
|
# 将.env环境变量配置文件拷贝致gitea runner容器
|
||||||
run: npm config set registry https://registry.npmmirror.com
|
- name: copy env file to runner container
|
||||||
|
uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/ssh-action@main
|
||||||
### https://github.com/pnpm/action-setup
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: https://shanshanzhong147@gmail.com:shanshanzhong147@git.kxsw.us/actions/action-setup
|
|
||||||
with:
|
with:
|
||||||
version: 9.15.9
|
host: ${{ env.SSH_HOST }}
|
||||||
run_install: false
|
username: ${{ env.SSH_USER }}
|
||||||
|
password: ${{ env.SSH_PASSWORD }}
|
||||||
|
port: ${{ env.SSH_PORT }}
|
||||||
|
debug: true
|
||||||
|
script: |
|
||||||
|
mkdir -p ~/cicd_env_files
|
||||||
|
cd ~/cicd_env_files
|
||||||
|
rm -f ./.env
|
||||||
|
docker cp ${{ vars.JOB_CONTAINER_NAME }}:${{ github.workspace }}/deploy/.env ./.env
|
||||||
|
source ./.env
|
||||||
|
if [ -n "${{ vars.RUNNER_CONTAINER_NAME }}" ]; then
|
||||||
|
docker cp .env ${{ vars.RUNNER_CONTAINER_NAME }}:/.env
|
||||||
|
docker exec ${{ vars.RUNNER_CONTAINER_NAME }} /bin/bash -c "source /.env"
|
||||||
|
else
|
||||||
|
echo "RUNNER_CONTAINER_NAME is not set, skipping container operations"
|
||||||
|
fi
|
||||||
|
|
||||||
- id: tool-cache
|
- name: Setup Go environment with cache
|
||||||
uses: https://shanshanzhong147@gmail.com:shanshanzhong147@git.kxsw.us/actions/gitea-tool-cache
|
uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/setup-go@main
|
||||||
with:
|
with:
|
||||||
# 只有node支持版本号别名
|
go-version: ${{ matrix.go }}
|
||||||
node-version: lts
|
cache: true
|
||||||
|
cache-dependency-path: go.sum
|
||||||
|
|
||||||
- uses: https://shanshanzhong147@gmail.com:shanshanzhong147@git.kxsw.us/actions/setup-node
|
|
||||||
with:
|
|
||||||
# gitea-tool-cache导出 node 具体版本
|
|
||||||
node-version: ${{ steps.tool-cache.outputs.node-version }}
|
|
||||||
registry-url: https://registry.npmmirror.com
|
|
||||||
cache: pnpm
|
|
||||||
|
|
||||||
- name: set cavans registry
|
|
||||||
run: pnpm config set canvas_binary_host_mirror https://registry.npmmirror.com/-/binary/canvas
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: Run Build Project
|
|
||||||
run: pnpm run build
|
|
||||||
|
|
||||||
- name: Run Build Docker
|
|
||||||
run: make build
|
|
||||||
|
|
||||||
|
- name: Build and push docker image
|
||||||
|
run: |
|
||||||
|
source ${{ gitea.workspace }}/deploy/.env
|
||||||
|
go mod tidy
|
||||||
|
make build-linux
|
||||||
|
make docker
|
||||||
|
make publish-docker
|
||||||
|
make docker-run
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user