microCMS ã®ã³ã³ãã³ãæ´æ°ã®ã¿ã¤ãã³ã°ã§ Vercel (ZEIT Now) ãåãã«ãã»ãããã¤ããã
ååã¯ãGridsome x microCMSãç¨ããç°¡åãªããã°ãµã¤ããæ§ç¯ããã
ãã㧠npm run build
ã§çæãããã¡ã¤ã«ãNetlify / Vercelçã¸ãã¹ãã£ã³ã°ãããã¨ãããã°ãµã¤ãã¨ãã¦å
¬éã§ããã
ãããããã®ã¾ã¾ã§ã¯microCMSã®ã³ã³ãã³ãæ´æ°ããããã³ãNetlify / Vercelã®ãããªãã¹ãã£ã³ã°ãµã¼ãã¹ã§åãã«ãã»ãããã¤ããªãã¦ã¯ãªããªãã
æ¬è¨äºã§ã¯ãä¸è¨ã®æéãæ¹åããmicroCMS ã®ã³ã³ãã³ãæ´æ°ã®ã¿ã¤ãã³ã°ã§ Vercelï¼ZEIT Nowï¼ ãåãã«ãã»ãããã¤ãããéã®æé ãæ¸ãæ®ãã
Vercel ï¼ZEIT Nowï¼ã¨ã¯ï¼
ãã³ã³ã¼ãã£ã³ã°ã§ãããã¤ãã§ãããµã¼ãã¹ãåã¯Nowã¨ãããµã¼ãã¹ã ã£ãããVercelã«å¤æ´ãããæ§åã
Vercel CLIã使ããã¨ã§ã
# Vercel CLIãã°ãã¼ãã«ã¤ã³ã¹ãã¼ã« npm i -g now # ã«ã¬ã³ããã£ã¬ã¯ããªãããã㤠now
ã ãã§ãããã¤ã§ããã
ç¡æãã©ã³ï¼Hobbyï¼ã¯ Free, forever
ï¼æ°¸é ã«ç¡æï¼ã¨ã®ãã¨ã
ãµã¯ãã¨ãã¼ããã©ãªãªãå人ããã°ãµã¤ããå ¬éããã®ã«è¯ãé¸æè¢ãããããªãã
æé
ã®ãããã¤è¨å®ããã¨ãã®æé ãè¨è¼ããã
åæ
- GitHubã¸ãªãã¸ããªä½ææ¸ã¿
now
ãç¨ãã¦ããããã¤ãããã¨ããã
1. Vercel - Deployç¨ã®URLçºè¡
Vercelã¯ãGitHubãGitLabã®ãªãã¸ããªã¨é£æºããããã¨ã§ãURLãå©ãã¦ãã«ãã»ãããã¤ããDeploy Hookã®ä»çµã¿ãç¨æããã¦ããã
詳ããè¨å®æé ã¯ä¸è¨URLã«è¨è¼ããã¦ãããããã£ãã説æããã¨ä»¥ä¸ã
https://vercel.com/[GitHubã®ã¦ã¼ã¶ã¼å]/[ãªãã¸ããªå]/settings/git-integration
ã¸é·ç§»ãGitHubã®ãªãã¸ããªåãå ¥å- ãHook NameããGitHubã®ãã©ã³ãåããå
¥åå¾ã
Create Hook
ãæ¼ä¸ããã¨ããããã¤ç¨URLhttps://api.zeit.co/v1/integrations/deploy/hogehoge
ãçæããã
2. microCMS - ã«ã¹ã¿ã éç¥ã®è¨å®
microCMSã¯ãã³ã³ãã³ããAPIãå¤æ´ããã¿ã¤ãã³ã°ã§Webhookéç¥ã§ããã
種é¡ã¯ç¾æç¹ï¼2020/04ï¼ã§ã
- Slack
- Chatwork
- Netlify
- GitHub Actions
- ã¡ã¼ã«éç¥
- ã«ã¹ã¿ã éç¥
ãåå¨ãããä»åã¯ã«ã¹ã¿ã éç¥ã使ç¨ããã
ãã£ãã説æããã¨ã以ä¸ã®ãããªæé ã¨ãªãã
https://[ãµã¼ãã¹å].microcms.io/apis/[ã³ã³ãã³ãå]/settings/webhook
ã«é·ç§»- URLæ¬ã«å
ã»ã©çºè¡ãããããã¤ç¨URL
https://api.zeit.co/v1/integrations/deploy/hogehoge
ãå ¥å - URLãå©ãã¿ã¤ãã³ã°ã«ãã§ãã¯ããã
- URLæ¬ã«å
ã»ã©çºè¡ãããããã¤ç¨URL
è¨å®ã¯ããã ããããªãç°¡åã
ææ
æåã¯ä»¥ä¸ã®ãããªã¯ã¼ã¯ããã¼ãçµãã§ããããmicroCMSããã³ã³ãã³ãæ´æ°æã«ãããã¤ãæåãããæ¬è¨äºã®ãããªä»çµã¿ã«å¤ããã
- GitHubActionsã§microCMSã®ã³ã³ãã³ãæ´æ°ãåä¿¡
amondnet/now-deployment
ã使ã£ã¦ãVercelã®ãããã¤ãèµ°ããã
ãã¾ããããªãã£ãæã®GitHub Actionsã®ã¯ã¼ã¯ããã¼ã¯ä»¥ä¸ã
# https://github.com/zakizaki-ri9/javascript-sandbox/blob/master/.github/workflows/micro_cms_sample.yml name: microCMS Now Deploy on: # pushæã®æ¡ä»¶ push: branches: - master paths: - "gridsome-micro-cms-sample/**" - ".github/workflows/micro_cms_sample.yml" # microCMSãæ´æ°ãããã¨ãã®æ¡ä»¶ repository_dispatch: types: [micro_cms_updated] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: ref: "master" - run: | cd gridsome-micro-cms-sample - uses: amondnet/now-deployment@v2 with: zeit-token: ${{ secrets.MICROCMS_SAMPLE_NOW_ZEIT_TOKEN }} now-org-id: ${{ secrets.MICROCMS_SAMPLE_NOW_ORG_ID }} now-project-id: ${{ secrets.MICROCMS_SAMPLE_NOW_PROJECT_ID }} working-directory: "gridsome-micro-cms-sample"
ã ããä»èããã¨ã
ã®ããã«ããã°ã丸ãåã¾ã£ããããããªãã