diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b5e56b7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: Build + +on: + workflow_call: + workflow_dispatch: + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: '18.x' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build project + run: npm run build + + - name: Upload build + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist/ diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..64fa295 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,37 @@ +name: Deploy + +on: + pull_request: + types: + - closed + branches: + - master + workflow_dispatch: + +jobs: + tests: + name: Tests + uses: ./.github/workflows/tests.yml + + build: + name: Build + needs: [ tests ] + uses: ./.github/workflows/build.yml + + deploy: + name: Deploy + if: github.event.pull_request.merged == true + needs: [ build ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/download-artifact@v3 + with: + name: dist + path: dist + + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: dist diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..177eaa8 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,36 @@ +name: Tests + +on: + pull_request: + branches: + - master + workflow_call: + workflow_dispatch: + +jobs: + test: + name: Run Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: '18.x' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build project + run: npm run build + + - name: Run Tests + run: npm run test + + - name: Run Test Coverage + id: coverage + run: npm run coverage