[Steem Project] Travis-CI를 이용한 Gatsby 블로그 자동 배포하기

in #kr6 years ago (edited)

이전 글 [개츠비(gatsby)로 스팀잇 블로그 만들기]에서는 Travis-CI 자동 배포에 실패했었습니다. 이번에는 Travis-CI 에서 자동 배포에 성공하여 다시 포스팅합니다.

Travis-CI 는 깃허브에 사이트를 배포할 수 있습니다. 그리고 Cron Jobs 기능을 제공합니다. 저는 이 두 가지 기능 때문에 Netlify 보다는 Travis-CI 를 사용할 것 같습니다.


연관글


* * *

빌드 과정에서 오류가 발생하는 플러그인을 제거하였다. gatsby-config.js 파일을 수정하였다.

    {
      resolve: 'gatsby-transformer-remark',
      options: {
        plugins: [
          // {
          //   resolve: 'gatsby-remark-images',
          //   options: {
          //     maxWidth: 960
          //   }
          // },

gatsby-remark-images 은 마크다운에서 이미지를 처리하는 플러그인이다. 나는 스팀잇에 업로드한 이미지를 사용하기 때문에 해당 플러그인은 없어도 된다.



GITHUB_TOKEN 발급 받기


GitHub에서 Developer settings 메뉴의 Personam access toknes 페이지에 접속한다.

Personal access tokens: https://github.com/settings/tokens

Generate new token 버튼을 클릭한다.

repo 권한을 모두 선택한다. 그리고 Generate token 버튼을 클릭한다.


깃허브 access token 발급이 완료되었다. 참고로 이 페이지를 닫고 나면 access token은 다시 확인 할 수 없다.



Travis-ci를 이용하여 자동 배포하기


.travis.yml 파일을 생성한다. 설정에 대한 자세한 내용은 [공식 메뉴얼]을 참고한다.

language: node_js

node_js:
- "8"

cache:
  directories:
    - node_modules

# 배포 설정
deploy:
  provider: pages
  skip-cleanup: true
  keep-history: true
  github-token: $GITHUB_TOKEN
  local_dir: public
  on:
    branch: master

before_install:
  - npm install -g gatsby-cli

install:
  - npm install

script:
  - gatsby build --prefix-paths


Travis-CIRepositories에서 blog 프로젝트를 검색하여 활성화한다.

Travis-CI Repositories: https://travis-ci.org/account/repositories

Settings 버튼을 선택한다. 그리고 Environment Variables에 발급 받은 GITHUB_TOKEN 를 등록한다.

주기적으로 자동 배포를 실행하려면, Cron Jobs 을 활성화한다.

빌드(build)를 실행하면 아래와 같이 로그에서 과정을 볼 수 있다.

배포까지 끝나면 아래와 같이 완료되었다는 메세지를 볼 수 있다.

이제 24시간마다 블로그가 깃허브 페이지에 자동 배포가 될 것이다. 그리고 깃허브에 코드를 업데이트를 해도 자동 배포가 실행된다. 또는 Travis-CI 에서 강제로 빌드를 실행해도 된다.


* * *

이제 제가 원했던 스팀잇 블로그의 자동 배포 환경이 셋팅되었어요. Travis-CI 를 이용하면 24시간마다 자동 배포가 됩니다. 나중에는 스팀잇에 글 작성을 인지하고 자동 배포가 실행되도록 구현할 예정입니다.

이제부터 시간날때마다 블로그에 필요한 기능을 붙여나갈 예정입니다. 우선 구글 통계와 구글 광고 부터 삽입해봐야겠습니다.

여기까지 읽어주셔서 감사합니다.


Sponsored ( Powered by dclick )

dclick-imagead

Sort:  


@anpigon님 곰돌이가 6.6배로 보팅해드리고 가요~! 영차~

6.6배 보팅 감사합니다.

2019년 힘찬 새해의 붉은 태양처럼 가슴속 뜨거운 꿈을 향해 도전하시고, 그 꿈을 꼭 성취하시길 기원합니다. 좋은 일들만 가득한 한해되시길 바랍니다.

도깨비님 감사합니다. 도깨비님도 좋은일만 가득한 2019년이 되길 바랍니다.

Hi @anpigon!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 2.694 which ranks you at #13731 across all Steem accounts.
Your rank has improved 10 places in the last three days (old rank 13741).

In our last Algorithmic Curation Round, consisting of 261 contributions, your post is ranked at #222.

Evaluation of your UA score:
  • Only a few people are following you, try to convince more people with good work.
  • The readers like your work!
  • Try to work on user engagement: the more people that interact with you via the comments, the higher your UA score!

Feel free to join our @steem-ua Discord server

좋은 글 감사합니다.

최신 글이 블로그에 적용되려면 자동배포가 필요한 것인가요?

스팀잇글을 다운로드 받아서 사이트를 생성하기 때문에
스팀잇에 새 글을 작성하면 사이트를 다시 빌드&배포해야해요.

Congratulations @anpigon! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You got more than 2000 replies. Your next target is to reach 2250 replies.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Christmas Challenge - The party continues
Christmas Challenge - Send a gift to to your friends

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @anpigon! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 3000 upvotes. Your next target is to reach 4000 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Christmas Challenge - The party continues
Christmas Challenge - Send a gift to to your friends

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @anpigon! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 4000 upvotes. Your next target is to reach 5000 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Christmas Challenge - The party continues
Christmas Challenge - Send a gift to to your friends

Support SteemitBoard's project! Vote for its witness and get one more award!

스팀잇 블로그의 자동 배포라니,,,
평소에 그런게 있었으면 참 좋겠다고 생각 했는데 좋네요!!
GitHub 구경 해야겠네요!

평소에 저랑 같은 생각을 하셨군요.
카테고리 분류, 외부 사용자의 댓글,
그리고 구글 통계와 구글 광고를 달고 싶어서 외부 블로그가 있으면 좋겠다는 생각을 늘 하고 있었어요.

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.029
BTC 63439.39
ETH 2545.40
USDT 1.00
SBD 2.66