- 创建 Dockerfile 包含 PHP + Node.js + Git + SSH - 所有 workflow 使用本地镜像避免拉取延迟 - 需要先构建镜像: docker build -t gitea-runner-php:latest .
This commit is contained in:
@@ -12,11 +12,10 @@ jobs:
|
|||||||
name: 代码检查
|
name: 代码检查
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
container:
|
container:
|
||||||
image: composer:latest
|
image: gitea-runner-php:latest
|
||||||
steps:
|
steps:
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
run: |
|
run: |
|
||||||
apk add --no-cache git
|
|
||||||
git clone -b ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
|
git clone -b ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
|
||||||
git checkout ${{ github.sha }}
|
git checkout ${{ github.sha }}
|
||||||
|
|
||||||
@@ -47,12 +46,11 @@ jobs:
|
|||||||
name: 单元测试
|
name: 单元测试
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
container:
|
container:
|
||||||
image: composer:latest
|
image: gitea-runner-php:latest
|
||||||
needs: lint
|
needs: lint
|
||||||
steps:
|
steps:
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
run: |
|
run: |
|
||||||
apk add --no-cache git
|
|
||||||
git clone -b ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
|
git clone -b ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
|
||||||
git checkout ${{ github.sha }}
|
git checkout ${{ github.sha }}
|
||||||
|
|
||||||
@@ -71,6 +69,8 @@ jobs:
|
|||||||
ci-status:
|
ci-status:
|
||||||
name: CI 状态
|
name: CI 状态
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
|
container:
|
||||||
|
image: gitea-runner-php:latest
|
||||||
needs: [lint, test]
|
needs: [lint, test]
|
||||||
if: always()
|
if: always()
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -20,12 +20,9 @@ jobs:
|
|||||||
name: 部署测试环境
|
name: 部署测试环境
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
container:
|
container:
|
||||||
image: alpine:latest
|
image: gitea-runner-php:latest
|
||||||
if: github.ref == 'refs/heads/develop'
|
if: github.ref == 'refs/heads/develop'
|
||||||
steps:
|
steps:
|
||||||
- name: 安装依赖
|
|
||||||
run: apk add --no-cache openssh-client bash
|
|
||||||
|
|
||||||
- name: 设置 SSH 密钥
|
- name: 设置 SSH 密钥
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -67,12 +64,9 @@ jobs:
|
|||||||
name: 部署正式环境
|
name: 部署正式环境
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
container:
|
container:
|
||||||
image: alpine:latest
|
image: gitea-runner-php:latest
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
steps:
|
steps:
|
||||||
- name: 安装依赖
|
|
||||||
run: apk add --no-cache openssh-client bash
|
|
||||||
|
|
||||||
- name: 设置 SSH 密钥
|
- name: 设置 SSH 密钥
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ jobs:
|
|||||||
name: 快速测试
|
name: 快速测试
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
container:
|
container:
|
||||||
image: composer:latest
|
image: gitea-runner-php:latest
|
||||||
steps:
|
steps:
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
run: |
|
run: |
|
||||||
apk add --no-cache git
|
|
||||||
git clone -b ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
|
git clone -b ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
|
||||||
git checkout ${{ github.sha }}
|
git checkout ${{ github.sha }}
|
||||||
|
|
||||||
@@ -24,6 +23,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "PHP: $(php -v | head -1)"
|
echo "PHP: $(php -v | head -1)"
|
||||||
echo "Composer: $(composer --version)"
|
echo "Composer: $(composer --version)"
|
||||||
|
echo "Node: $(node -v)"
|
||||||
|
|
||||||
- name: PHP 语法检查
|
- name: PHP 语法检查
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# Gitea Actions Runner 专用镜像
|
||||||
|
# 包含完整的开发环境:PHP + Node.js + Git + SSH
|
||||||
|
|
||||||
|
FROM php:8.2-cli-bookworm
|
||||||
|
|
||||||
|
# 安装系统依赖
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
wget \
|
||||||
|
unzip \
|
||||||
|
openssh-client \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
libzip-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libcurl4-openssl-dev \
|
||||||
|
libonig-dev \
|
||||||
|
libmbstring-dev \
|
||||||
|
sqlite3 \
|
||||||
|
libsqlite3-dev \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# 安装 PHP 扩展
|
||||||
|
RUN docker-php-ext-install \
|
||||||
|
zip \
|
||||||
|
xml \
|
||||||
|
curl \
|
||||||
|
mbstring \
|
||||||
|
sqlite3 \
|
||||||
|
pdo \
|
||||||
|
pdo_sqlite \
|
||||||
|
pdo_mysql \
|
||||||
|
mysqli
|
||||||
|
|
||||||
|
# 安装 Composer
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
|
# 验证安装
|
||||||
|
RUN php -v && composer --version && node -v && npm -v
|
||||||
|
|
||||||
|
# 设置工作目录
|
||||||
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
# 默认命令
|
||||||
|
CMD ["bash"]
|
||||||
Reference in New Issue
Block a user