Skip to main content

CI FAQ

env

  • drone
    • DRONE_ 前缀
  • woodpecker
    • drone fork
    • CI_ 前缀
  • GitHub Action
    • GITHUB_ 前缀
# CI 环境识别
# ============
CI=true
CI=1
CI=woodpecker
GITLAB_CI=true
DRONE=true
GITHUB_ACTIONS=true
# Runtime & CI
VERCEL=1
RENDER=true
CLOUDFLARE_ACCOUNT_ID=

# CSV/Git 信息
# ============
CI_COMMIT_SHA=
CI_COMMIT_SHORT_SHA=$(git rev-parse --short HEAD)
CI_COMMIT_TAG=
CI_COMMIT_TAG_MESSAGE=
CI_COMMIT_TIMESTAMP=
CI_COMMIT_MESSAGE=
CI_COMMIT_DESCRIPTION=
CI_COMMIT_BRANCH=
CI_COMMIT_REF=
CI_COMMIT_REF_NAME=
CI_COMMIT_REF_SLUG=$(echo $CI_COMMIT_REF_NAME | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g' | sed 's/^-//g' | sed 's/-*$//g' | sed 's/-\{2,\}/-/g')
CI_COMMIT_BEFORE_SHA=0000000000000000000000000000000000000000

# Gitlab
# ============
CI_REGISTRY=
CI_REGISTRY_USER=
CI_REGISTRY_PASSWORD=
CI_REGISTRY_IMAGE=

CI_DEFAULT_BRANCH=
CI_REPOSITORY_URL=

# GitHub
# ============
GITHUB_ACTION=__repo-owner_name-of-action-repo

# Jenkins
# ============
JOB_NAME=
JOB_URL=
EXECUTOR_NUMBER=0
BUILD_NUMBER=1

GIT_COMMIT=
# GIT_{COMMITTER,AUTHOR}_{NAME,EMAIL}=
GIT_URL=
GIT_BRANCH=
GIT_LOCAL_BRANCH=
GIT_PREVIOUS_COMMIT=
GIT_PREVIOUS_SUCCESSFUL_COMMIT=

snipptes

  • NPM_TOKEN
    • A://registry.npmjs.org:_authToken,B://registry.npmjs.org:_authToken
# TOKEN://registry
[ -n "$NPM_TOKEN" ] && {
echo NPM Login
echo "$NPM_TOKEN" |
tr ',' '\n' |
xargs -I {} sh -c 'X="{}";npm config set -L user "$(echo $X|cut -d: -f2- ):_authToken" "$(echo $X|cut -d: -f1)"'
}

[ -z "$DOCKER_REGISTRY" ] || docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" "$DOCKER_REGISTRY"

# github secrets
[ -z "${{ secrets.DOCKER_REGISTRY }}" ] || docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}" "${{ secrets.DOCKER_REGISTRY }}"
- name: Install
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
set -e
# TOKEN://registry
[ -n "$NPM_TOKEN" ] && {
echo NPM Login
echo "$NPM_TOKEN" |
tr ',' '\n' |
xargs -I {} sh -c 'X="{}";npm config set -L user "$(echo $X|cut -d: -f2- ):_authToken" "$(echo $X|cut -d: -f1)"'
}

time npm add -g pnpm@latest
time CI=true \
PUPPETEER_SKIP_DOWNLOAD=true \
make install