# 1. Docker Image # 사용할 docker image를 지정해 줍니다. image: node:latest # 2. Stages # stages 순서대로 pipeline이 형성됩니다. stages: - build - deploy - publish # 3. Cache # 이 전 작업과 동일한 내용인지를 확인해서 재사용 해주는 캐싱 메커니즘의 옵션입니다. cache: paths: - node_modules/ before_script: - echo "started by ${GITLAB_USER_NAME}" # 4. Build build: stage: build script: - npm install - npm run build artifacts: # artifacts의 기능을 활용하면 stage의 결과를 다음 stage가 사용할 수 있도록 도와주며 그렇게 만들어진 결과 파일등을 만료시키는 시간 역시 정해줄 수 있습니다. expire_in: 1 hour paths: - build/ only: # 해당 stage는 master branch에서만 실행 가능하도록 설정해 줍니다. - master # 5. Deploy deploy: stage: deploy image: python:latest # aws cli를 설치하기 위해서 python image 를 사용합니다. script: # aws s3 sync 명령어를 활용하여 빌드된 파일을 나의 버킷에 올려주고 public-read 가 가능하도록 설정해 줍니다. - pip install awscli - aws s3 sync . s3://editor.superclubs.io --acl public-read --exclude '*' --include 'index.html' --include 'app.css' --include 'build/*' - aws cloudfront create-invalidation --distribution-id $AWS_DISTRIBUTION_ID --paths "/*" only: - master # 6. Publish publish: stage: publish script: - git config --global user.email "sunus7@naver.com" - git config --global user.name "Sunwook Kim" - npm version patch -f - npm install - npm run build - git push https://${GITLAB_USER_LOGIN}:${GITLAB_TOKEN}@gitlab.ccr.co.kr/cgp_ex/frontend/idist-jodit.git HEAD:${CI_COMMIT_REF_NAME} --follow-tags - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - npm publish when: manual only: - master