From 497cfeecb9c733e38aa84c65a87ea5829bbc4627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=A7=E1=86=BC?= Date: Mon, 11 Dec 2023 19:52:50 +0900 Subject: [PATCH] Chore : set github actions CI flow --- .github/workflows/main.yml | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..45f3df5 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,68 @@ +name: CI + +on: + push: + branches: [release] + pull_request: + branches: [release] + + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-20.04 + env: + REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }} + REACT_APP_SOCIAL_URL: ${{ secrets.REACT_APP_SOCIAL_URL }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: '${{ secrets.AWS_REGION }}' + + steps: + - name: Checkout source code. + uses: actions/checkout@master + + - name: Cache node modules + uses: actions/cache@v1 + with: + path: node_modules + key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-build- + ${{ runner.OS }}- + + - name: Generate Environment Variables File for Production + run: | + echo "REACT_APP_BASE_URL=$REACT_APP_BASE_URL" >> .env.production + echo "REACT_APP_SOCIAL_URL=$REACT_APP_SOCIAL_URL" >> .env.production + echo "REACT_APP_SOCKET_BASE_URL=$REACT_APP_SOCKET_BASE_URL" >> .env.production + echo "REACT_APP_IMAGE_BUCKET=$REACT_APP_IMAGE_BUCKET" >> .env.production + echo "REACT_APP_ACCESS_KEY=$REACT_APP_ACCESS_KEY" >> .env.production + echo "REACT_APP_SECRET_ACCESS_KEY=$REACT_APP_SECRET_ACCESS_KEY" >> .env.production + echo "REACT_APP_REGION=$REACT_APP_REGION" >> .env.production + + env: + REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }} + REACT_APP_SOCIAL_URL: ${{ secrets.REACT_APP_SOCIAL_URL }} + REACT_APP_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + REACT_APP_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + REACT_APP_REGION: ${{ secrets.AWS_REGION }} + + - name: Install Dependencies + run: npm install + + - name: Build + run: CI=false npm run build + + - name: Deploy + run: | + aws s3 sync \ + --region ${{ secrets.AWS_REGION }} \ + build s3://${{ secrets.AWS_S3_BUCKET_NAME }} \ + --delete + + - name: Invalidate cache CloudFront + uses: chetan/invalidate-cloudfront-action@master + env: + DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION }} + PATHS: '/index.html' + continue-on-error: true