Merge branch 'sprint/COT-25_attendance_admin_view' into release #274
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- '*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.npm | |
~/.yarn | |
node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Check Node v | |
run: node -v | |
- name: Set Environment Variables | |
run: | | |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then | |
echo "REACT_APP_BASE_URL=${{ secrets.REACT_APP_BASE_URL }}" >> .env | |
echo "REACT_APP_SOCKET_URL=${{ secrets.REACT_APP_SOCKET_URL }}" >> .env | |
echo "REACT_APP_SENTRY_DSN=${{ secrets.REACT_APP_SENTRY_DSN }}" >> .env | |
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> .env | |
elif [ "${GITHUB_REF}" == "refs/heads/release" ]; then | |
echo "REACT_APP_BASE_URL=${{ secrets.REACT_APP_QA_BASE_URL }}" >> .env | |
echo "REACT_APP_SOCKET_URL=${{ secrets.REACT_APP_QA_SOCKET_URL }}" >> .env | |
echo "REACT_APP_SENTRY_DSN=${{ secrets.REACT_APP_SENTRY_DSN }}" >> .env | |
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> .env | |
fi | |
env: | |
REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }} | |
REACT_APP_SOCKET_URL: ${{ secrets.REACT_APP_SOCKET_URL }} | |
REACT_APP_QA_BASE_URL: ${{ secrets.REACT_APP_QA_BASE_URL }} | |
REACT_APP_QA_SOCKET_URL: ${{ secrets.REACT_APP_QA_SOCKET_URL }} | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Install Sentry CLI | |
run: yarn global add @sentry/cli | |
- name: Build | |
run: yarn build | |
- name: Upload sourcemaps to Sentry | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
run: | | |
sentry-cli sourcemaps inject --org cotato-fe --project cotato build | |
sentry-cli sourcemaps upload --org cotato-fe --project cotato build | |
- name: Save Build Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifact | |
path: | | |
build | |
appspec.yml | |
deploy.sh | |
production-deploy: | |
needs: build | |
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release' | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-artifact | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
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: Zip Build Folder | |
run: zip -qq -r build-fe.zip build appspec.yml deploy.sh | |
shell: bash | |
- name: Upload to S3 | |
run: | | |
aws s3 cp build-fe.zip s3://${{ secrets.AWS_S3_BUCKET_NAME }}/build-fe.zip --region ap-northeast-2 | |
- name: Deploy | |
run: | | |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then | |
DEPLOYMENT_GROUP_NAME="cotato-deploy-fe-production" | |
elif [ "${GITHUB_REF}" == "refs/heads/release" ]; then | |
DEPLOYMENT_GROUP_NAME="cotato-deploy-fe-release" | |
fi | |
aws deploy create-deployment \ | |
--application-name cotato-deploy \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--deployment-group-name ${DEPLOYMENT_GROUP_NAME} \ | |
--s3-location bucket=${{ secrets.AWS_S3_BUCKET_NAME }},key=build-fe.zip,bundleType=zip |