Skip to content

Create deploy.yml

Create deploy.yml #1

Workflow file for this run

name: Deploy to Deploy 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 checkout deploy
git rm -rf .
git checkout main -- .
git add .
git commit -m "Copy files from main to deploy branch"
git push origin deploy
- name: Install dependencies and build
run: |
git checkout deploy
npm install
npm run build
- name: Remove files and folders except dist
run: |
git checkout deploy
find . -type f -not -path './dist/*' -delete
find . -type d -not -path './dist' -delete
- name: Move files from dist to root
run: |
git checkout deploy
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 branch"
git push origin deploy