Skip to content

Commit 1e3a588

Browse files
authored
feat: split workflow to multiple workflows for better overview, close… (#6)
feat: split workflow to multiple workflows for better overview, closes #5
1 parent 1acb93d commit 1e3a588

File tree

8 files changed

+147
-24
lines changed

8 files changed

+147
-24
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "NPM Cache Action"
2+
description: "Initialize NPM Cache"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- uses: actions/cache@v3
7+
id: "npm-cache" # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
8+
with:
9+
path: "./node_modules"
10+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
11+
restore-keys: |
12+
${{ runner.os }}-node-

.github/workflows/00-init.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Init Workflow
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
init:
8+
name: Init
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: 🛑 Cancel Previous Runs
12+
uses: styfle/[email protected]
13+
14+
- name: ⬇️ Checkout repo
15+
uses: actions/checkout@v3
16+
17+
- name: 🔄 Init Cache Default
18+
uses: ./.github/actions/npm-cache
19+
20+
- name: 📥 Download deps default-npm-cache
21+
if: steps.npm-cache.outputs.cache-hit != 'true'
22+
uses: bahmutov/npm-install@v1

.github/workflows/01-build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build Pages
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
name: Build
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: ⬇️ Checkout repo
12+
uses: actions/checkout@v3
13+
14+
- name: 🔄 Init Cache
15+
uses: ./.github/actions/npm-cache
16+
17+
- name: 🍼 Create pages build
18+
run: npm run build
19+
20+
- name: ⬆️Upload build
21+
uses: actions/upload-artifact@v3
22+
with:
23+
name: build
24+
path: public

.github/workflows/01-lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
lint:
8+
name: Lint
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: ⬇️ Checkout repo
12+
uses: actions/checkout@v3
13+
14+
- name: 🔄 Init Cache
15+
uses: ./.github/actions/npm-cache
16+
17+
- name: ⚡ Run Test
18+
run: npm run lint

.github/workflows/01-test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
name: Test
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: ⬇️ Checkout repo
12+
uses: actions/checkout@v3
13+
14+
- name: 🔄 Init Cache
15+
uses: ./.github/actions/npm-cache
16+
17+
- name: ⚡ Run Test
18+
run: npm run test
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy to gh-pages
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
deploy:
8+
name: Deploy
9+
runs-on: ubuntu-latest
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
steps:
13+
- name: ⬇️ Checkout repo
14+
uses: actions/checkout@v3
15+
16+
- name: 🔄 Init Cache
17+
uses: ./.github/actions/npm-cache
18+
19+
- name: ⬇️Download build
20+
uses: actions/download-artifact@v3
21+
with:
22+
name: build
23+
path: public
24+
25+
- name: 🥅 Deploy to GH-Pages
26+
uses: peaceiris/actions-gh-pages@v3
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
publish_dir: ./public

.github/workflows/default.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Default push workflow
2+
3+
on: [push]
4+
5+
jobs:
6+
init:
7+
uses: ./.github/workflows/00-init.yml
8+
9+
lint:
10+
uses: ./.github/workflows/01-lint.yml
11+
needs: [init]
12+
13+
test:
14+
uses: ./.github/workflows/01-test.yml
15+
needs: [init]
16+
17+
build:
18+
uses: ./.github/workflows/01-build.yml
19+
needs: [init]
20+
21+
deploy:
22+
if: contains( github.ref, 'main')
23+
uses: ./.github/workflows/02-deploy-gh-pages.yml
24+
needs: [lint, test, build]

.github/workflows/gh_pages.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)