Skip to content

Instantly share code, notes, and snippets.

@khoipro
Last active June 1, 2020 04:55
Show Gist options
  • Select an option

  • Save khoipro/fea2927ffbf5087cf0284773a9c13c1d to your computer and use it in GitHub Desktop.

Select an option

Save khoipro/fea2927ffbf5087cf0284773a9c13c1d to your computer and use it in GitHub Desktop.
image: "node:12-alpine"
stages:
- build
- test
- deploy
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .npm-cache/
before_script:
- 'which ssh-agent || ( apk add --update openssh git )'
- eval $(ssh-agent -s)
- echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_PUBLIC_KEY" >> ~/.ssh/id_rsa.pub
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- git config --global user.name "${CI_USERNAME}"
- git config --global user.email "${CI_EMAIL}"
- cd wp-content/themes/$THEME_NAME
- npm ci --cache .npm-cache --prefer-offline
build_theme:
stage: build
script:
- npm run build
- git add assets/
- git commit -m "Process styles and scripts [skip ci]"
- git remote rm origin && git remote add origin [email protected]:$CI_PROJECT_PATH.git
- git fetch origin
- git push origin HEAD:$CI_COMMIT_REF_NAME
artifacts:
paths:
- assets/
only:
- develop
test_theme:
stage: test
script:
- npm run test
only:
- /(feature|bugfix|hotfix)\/?(.*)/

WordPress Theme Development Flow

develop

  • Create a top commit "Process styles and scripts" on the top of develop branch with command npm run build (guess an assets folder is assets/).

bugfix/hotfix/feature/

  • Verify a code by command npm run test

CI Variables

  • SSH_PRIVATE_KEY
  • SSH_PUBLIC_KEY
  • THEME_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment