diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..b9f7b175 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,48 @@ +name: deploy-to-42ByteClientS3 + +on: + push: + branches: [deploy] + +jobs: + build: + runs-on: ubuntu-18.04 + steps: + - name: git clone + uses: actions/checkout@v2 + + - name: npm install for eslint + run: npm install + + - name: npm install + run: npm install + working-directory: ./client + + - name: build + env: + REACT_APP_ACCESS_ID: ${{ secrets.REACT_APP_ACCESS_ID }} + REACT_APP_ACCESS_KEY: ${{ secrets.REACT_APP_ACCESS_KEY }} + REACT_APP_BUCKET_NAME: ${{ secrets.REACT_APP_BUCKET_NAME }} + REACT_APP_REGION: ${{ secrets.REACT_APP_REGION }} + REACT_APP_SERVERIP: ${{ secrets.REACT_APP_SERVERIP }} + run: CI='' npm run build + working-directory: ./client + + - name: Transfer to S3 for serving static + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: ${{ secrets.AWS_BUCKET_NAME }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_IAM_MANAGER_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_IAM_MANAGER_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_BUCKET_REGION }} + SOURCE_DIR: '/home/runner/work/blind-42/42byte/client/build' + + - name: 캐시 무효화 + env: + AWS_S3_BUCKET: ${{ secrets.AWS_BUCKET_NAME }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_IAM_MANAGER_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_IAM_MANAGER_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_BUCKET_REGION }} + run: aws cloudfront create-invalidation --distribution-id=E12HWSI28LDLX4 --paths "/*"