๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๊ฐœ๋ฐœ/WEB

Vue ์‹œ์ž‘ํ•˜๊ธฐ (4) | Github actions + S3๋กœ ๋ฐฐํฌ ์ž๋™ํ™”

๋ฐ˜์‘ํ˜•

 

๐Ÿ“„ ๋ชฉ์ฐจ

     

    1. Amazon IAM ์ƒ์„ฑ

     

    1. ์‚ฌ์šฉ์ž ์ด๋ฆ„, ์ž๊ฒฉ์ฆ๋ช… ์œ ํ˜• ์„ ํƒ

    2. ๊ถŒํ•œ ์„ค์ •

    ๋‚˜๋จธ์ง€๋Š” ๋‹ค์Œ ๋‹ค์Œ ๋ˆŒ๋Ÿฌ์„œ ๋„˜๊ฒจ์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

    ์‚ฌ์šฉ์ž ์ถ”๊ฐ€๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด  ํ‚ค๊ฐ€ ํฌํ•จ๋œ csv๋ฅผ ๋‹ค์šด๋กœ๋“œ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

     

     

    2. github secrets ์„ธํŒ…

     

    ๊นƒํ—™ ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒˆ๋กœ ์ƒ์„ฑํ•˜์—ฌ ์ž‘์—…ํ•œ vue ํ”„๋กœ์ ํŠธ๋ฅผ ์—…๋กœ๋“œ ํ•ฉ๋‹ˆ๋‹ค. 

     

    Settingsํƒญ > secrets > actions > New repository secret 

    ์•„๊นŒ S3์—์„œ ์ƒ์„ฑํ•œ key id์™€ secret์„ ๊ฐ๊ฐ AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY ์ด๋ฆ„์œผ๋กœ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค. 

     

     

    3. github workflows์ •์˜

    ํ”„๋กœ์ ํŠธ์˜ ๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌ์—

    .github/workflows ํด๋”๋ฅผ ๋งŒ๋“ค๊ณ  ํ•˜์œ„์— deploy.yml ํŒŒ์ผ์„ ์ƒ์„ฑํ•ด์ค๋‹ˆ๋‹ค.

     

    name: Deploy
    
    on:
      push:
        branches:
          - [๋ธŒ๋žœ์น˜๋ช…]
    
    jobs:
      deploy:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
          - name: Cache modules
            uses: actions/cache@v1
            id: yarn-cache
            with:
              path: node_modules
              key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
              restore-keys: ${{ runner.os }}-yarn-
          - name: Configure AWS credentials
            uses: aws-actions/configure-aws-credentials@v1
            with:
              aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
              aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
              aws-region: ap-northeast-2
          - name: Use Node.js 12.x
            uses: actions/setup-node@v1
            with:
              node-version: 12.x
          - name: Install dependencies
            run: yarn
          - name: Build
            run: yarn build
          - name: Deploy
            run: aws s3 sync ./dist s3://[๋ฒ„ํ‚ท๋ช…]

     

    branches: ์ชฝ์— workflow๋ฅผ ํŠธ๋ฆฌ๊ฑฐํ•  branch๋ฅผ ์ •์˜ํ•ด์ฃผ์„ธ์š”. ์ €๋Š” main๋ธŒ๋žœ์น˜๋กœ ํ–ˆ์Šต๋‹ˆ๋‹ค.

    ๊ทธ๋ฆฌ๊ณ  ๋งจ ์•„๋ž˜์— S3 ๋ฒ„ํ‚ท๋ช…์€ ๋ณธ์ธ์ด ๋งŒ๋“  ๋ฒ„ํ‚ท ๋ช…์œผ๋กœ ์ˆ˜์ •ํ•ด์ฃผ์„ธ์š”. 

     

     

    ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์„ ํ‘ธ์‹œํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด workflow๊ฐ€ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

     

     

     

    ์›น์‚ฌ์ดํŠธ์— ๋ฐฉ๋ฌธํ•ด๋ณด๋ฉด ์ˆ˜์ •์‚ฌํ•ญ์ด ์ž˜ ๋ฐ˜์˜๋˜๋Š”๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

    ๋ฐ˜์‘ํ˜•