Skip to content

feat: split workflow to multiple workflows for better overview, closes #3 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/actions/npm-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "NPM Cache Action"
description: "Initialize NPM Cache"
runs:
using: "composite"
steps:
- uses: actions/cache@v3
id: "npm-cache" # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: "./node_modules"
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
Copy link
Member

@mfranzke mfranzke Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something missing at the end of this string? Mainly because it ends with a dash and I would expect something further to come after that.

22 changes: 22 additions & 0 deletions .github/workflows/00-init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Init Workflow

on:
workflow_call:

jobs:
init:
name: Init
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🔄 Init Cache Default
uses: ./.github/actions/npm-cache

- name: 📥 Download deps default-npm-cache
if: steps.npm-cache.outputs.cache-hit != 'true'
uses: bahmutov/npm-install@v1
24 changes: 24 additions & 0 deletions .github/workflows/01-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build Pages

on:
workflow_call:

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🔄 Init Cache
uses: ./.github/actions/npm-cache

- name: 🍼 Create pages build
run: npm run build

- name: ⬆️Upload build
uses: actions/upload-artifact@v3
with:
name: build
path: public
18 changes: 18 additions & 0 deletions .github/workflows/01-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint

on:
workflow_call:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🔄 Init Cache
uses: ./.github/actions/npm-cache

- name: ⚡ Run Test
run: npm run lint
18 changes: 18 additions & 0 deletions .github/workflows/01-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test

on:
workflow_call:

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🔄 Init Cache
uses: ./.github/actions/npm-cache

- name: ⚡ Run Test
run: npm run test
29 changes: 29 additions & 0 deletions .github/workflows/02-deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy to gh-pages

on:
workflow_call:

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🔄 Init Cache
uses: ./.github/actions/npm-cache

- name: ⬇️Download build
uses: actions/download-artifact@v3
with:
name: build
path: public

- name: 🥅 Deploy to GH-Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
26 changes: 26 additions & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Default push workflow

on: [push]

jobs:
init:
uses: ./.github/workflows/00-init.yml

# TODO: Reactivate when test and lint works
# lint:
# uses: ./.github/workflows/01-lint.yml
# needs: [init]
#
# test:
# uses: ./.github/workflows/01-test.yml
# needs: [init]

build:
uses: ./.github/workflows/01-build.yml
needs: [init]

deploy:
if: contains( github.ref, 'main')
uses: ./.github/workflows/02-deploy-gh-pages.yml
# needs: [lint, test, build]
needs: [build]
24 changes: 0 additions & 24 deletions .github/workflows/gh_pages.yml

This file was deleted.