Skip to content

build: change ci script #13

build: change ci script

build: change ci script #13

Workflow file for this run

name: Deploy React App
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Create .env file from secret
run: |
echo "${{ secrets.APP_ENV }}" | base64 --decode > .env
- name: Build the React app
run: npm run build
- name: Push built app to deployment repository
env:
GH_TOKEN: ${{ secrets.AUTO_ACTIONS }}
run: |
TARGET_REPO="ajou-chong/ajouchong-admin"
CLONE_DIR="deploy-repo"
DEPLOY_BRANCH="${GITHUB_REF##*/}"
git clone --depth=1 https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git $CLONE_DIR
rsync -av --exclude=deploy-repo/ ./ deploy-repo/
cd $CLONE_DIR
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if git show-ref --verify --quiet refs/heads/${DEPLOY_BRANCH}; then
git checkout ${DEPLOY_BRANCH}
else
git checkout -b ${DEPLOY_BRANCH}
fi
git add .
git commit -m "Deploy app [${{ github.sha }}]"
git push -f origin ${DEPLOY_BRANCH}