Merge pull request #38 from rishavranjan943/main #27
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: Deploy to deploy-main branch | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Copy files from main to deploy branch | |
env: | |
PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | |
run: | | |
git config --global user.name 'GitHub Action' | |
git config --global user.email '[email protected]' | |
git checkout -b deploy-main | |
git rm -rf . | |
git checkout main -- . | |
- name: Install dependencies and build | |
run: | | |
git checkout deploy-main | |
npm install | |
npm run build | |
- name: Remove files and folders except dist | |
run: | | |
git checkout deploy-main | |
rm -r $(ls -A | grep -v dist | grep -v .git) | |
- name: Move files from dist to root | |
run: | | |
git checkout deploy-main | |
mv dist/* . | |
rm -rf dist | |
- name: Commit and push changes | |
env: | |
PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | |
run: | | |
git add . | |
git commit -m "Push build files to deploy-main branch" | |
git push origin deploy-main -f |