بازگشت به بلاگ

استفاده از میرور در CI/CD (GitHub Actions, GitLab)

۱۴۰۵/۰۳/۰۸۶ دقیقه مطالعه
CI/CDDevOps

یکی از بزرگ‌ترین مشکلات CI/CD در ایران، ناپایداری دانلود پکیج‌ها در pipeline است. با استفاده از میرور ای‌پیمارت، build‌های شما سریع‌تر و پایدارتر می‌شوند.

GitHub Actions

در فایل workflow خود، قبل از npm install این step را اضافه کنید:

- name: Set npm mirror
  run: npm config set registry https://mirror.ipmartnet.work/npm/

مثال کامل:

name: Build
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm config set registry https://mirror.ipmartnet.work/npm/
      - run: npm ci
      - run: npm run build

GitLab CI

در فایل .gitlab-ci.yml:

variables:
  NPM_CONFIG_REGISTRY: https://mirror.ipmartnet.work/npm/

build:
  image: node:20
  script:
    - npm ci
    - npm run build

Docker

در Dockerfile خود:

FROM node:20-alpine
RUN npm config set registry https://mirror.ipmartnet.work/npm/
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

Python (pip) در CI

- name: Install dependencies
  run: pip install -r requirements.txt --index-url https://mirror.ipmartnet.work/pypi/simple/

Go در CI

- name: Set Go proxy
  run: go env -w GOPROXY=https://mirror.ipmartnet.work/go,direct

نکته مهم

اگر سرور CI/CD شما در ایران است، حتماً IP آن را در داشبورد ای‌پیمارت ثبت کنید تا محدودیت ۵۰۰ درخواست رایگان برای آن اعمال نشود. بسته سازمانی برای CI/CD ایده‌آل است.

آماده استفاده از میرور ای‌پیمارت هستید؟