Merge pull request #3 from caykay/pr_githubWorkflow #49
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 | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build and Push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Setup Node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16 | |
- name: Install dependencies | |
uses: bahmutov/npm-install@v1 | |
- name: Build project | |
run: npm run build | |
# check that the current branch we are on is the main branch | |
# if it is, then push the build branch | |
# if it is not, then do nothing | |
- name: create/update build branch | |
if: github.ref == 'refs/heads/main' | |
run: git branch -f build | |
- name: Push and Deploy | |
if: github.ref == 'refs/heads/main' | |
uses: s0/git-publish-subdir-action@develop | |
env: | |
REPO: self | |
BRANCH: build # The branch name where you want to push the assets | |
FOLDER: build # The directory where your assets are generated | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token | |
MESSAGE: "Build: ({sha}) {msg}" # The commit message |