Update deploy.yml #7
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: Build and push | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
env: | |
TARGET_BRANCH: "build" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build | |
run: pnpm run build | |
- name: Copy build artifacts to the target branch | |
run: | | |
git fetch # fetch branches | |
git checkout ${TARGET_BRANCH} # checkout to your branch | |
git merge origin/main --no-edit # merge the main branch to your branch | |
cp -r dist/* storefront # move all files from dist to storeferont | |
- name: Commit and push changes | |
run: | | |
git config --global user.name 'devops-devdocs' # set your username | |
git config --global user.email '[email protected]' # set your email | |
git add --all # add all changed files | |
git diff-index --quiet HEAD || git commit -am "$(git rev-parse --short $GITHUB_SHA): deploy files" # commit to the repository (ignore if no modification) | |
git push origin ${TARGET_BRANCH} # push to the remote target branch |