Skip to content

Commit

Permalink
chore: Update deployment workflow to include build and deploy steps
Browse files Browse the repository at this point in the history
  • Loading branch information
codemile committed Jun 1, 2024
1 parent 53de44b commit 9f00408
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 180 deletions.
47 changes: 40 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
name: "🔨 Build"

on:
# When you push changes: only affected projects will be build/deploy
push:
branches:
- main
# When you manually trigger: all projects will be build/deploy
workflow_dispatch:
inputs:
testOnly:
description: "Run tests only?"
required: true
type: boolean
default: false
workflow_call:
inputs:
testOnly:
description: "Run tests only?"
required: true
type: boolean
default: false

concurrency: "build"

Expand All @@ -28,6 +37,12 @@ jobs:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "🔧 Setup node"
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
Expand All @@ -44,6 +59,12 @@ jobs:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "🔧 Setup node"
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
Expand All @@ -60,6 +81,12 @@ jobs:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "🔧 Setup node"
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@main
with:
Expand All @@ -71,15 +98,21 @@ jobs:
build:
runs-on: ubuntu-latest
needs: [ install ]
if: ${{ github.event.inputs.testOnly == false }}
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "🔧 Setup node"
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
mode: "restore"

- name: "🔨 Build projects"
- name: "🔨 Build"
run: yarn build

26 changes: 23 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ name: "🚀 Deploy"

on:
workflow_dispatch:
inputs:
skipDeploy:
description: "Skip deployment?"
required: true
type: boolean
default: false
workflow_call:
inputs:
skipDeploy:
description: "Skip deployment?"
required: true
type: boolean
default: false

concurrency: "deploy"

Expand All @@ -18,8 +31,14 @@ jobs:
mode: "install"

build:
runs-on: ubuntu-latest
needs: [ install ]
uses: ./.github/workflows/build.yml
with:
testOnly: true

artifacts:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4
Expand All @@ -40,7 +59,7 @@ jobs:
with:
static_site_generator: next

- name: "🔨 Build projects"
- name: "🔨 Build"
run: yarn build

- name: "📦 Upload artifact"
Expand All @@ -56,7 +75,8 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: [ build ]
needs: [ artifacts ]
if: ${{ github.event.inputs.skipDeploy == false }}
steps:
- name: "🚀 Deploy to GitHub Pages"
id: deployment
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "🚀 Main"

on:
push:
branches:
- main
workflow_dispatch:

concurrency: "main"

jobs:
install:
runs-on: ubuntu-latest
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "📦 Install dependencies"
uses: reactgular/cache@v1
with:
mode: "install"

build:
needs: [ install ]
uses: ./.github/workflows/build.yml
60 changes: 1 addition & 59 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,6 @@ jobs:
with:
mode: "install"

lint:
runs-on: ubuntu-latest
needs: [ install ]
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
mode: "restore"

- name: "🔨 Lint"
run: yarn lint

test:
runs-on: ubuntu-latest
needs: [ install ]
if: false
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
mode: "restore"

- name: "🔨 Test"
run: ${{ env.NX }} affected -t test

storybooks:
runs-on: ubuntu-latest
needs: [ install ]
if: false
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
mode: "restore"

- name: "🔨 Build storybooks"
run: yarn build-storybook

build:
runs-on: ubuntu-latest
needs: [ install ]
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
mode: "restore"

- name: "🔨 Build projects"
run: yarn build
uses: ./.github/workflows/build.yml
115 changes: 4 additions & 111 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,106 +41,13 @@ jobs:
outputs:
package_version: ${{ steps.version.outputs.version }}

lint:
runs-on: ubuntu-latest
needs: [ install ]
if: false
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
mode: "restore"

- name: "🔨 Lint"
run: yarn lint

test:
runs-on: ubuntu-latest
needs: [ install ]
if: false
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
mode: "restore"

- name: "🔨 Test"
run: ${{ env.NX }} affected -t test

storybooks:
runs-on: ubuntu-latest
needs: [ install ]
if: false
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@main
with:
mode: "restore"

- name: "🔨 Build storybooks"
run: yarn build-storybook

build:
runs-on: ubuntu-latest
needs: [ install ]
steps:
- name: "📥 Checkout code"
uses: actions/checkout@v4

- name: "🔧 Setup Node"
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: "💽 Restore node_modules cache"
uses: reactgular/cache@v1
with:
mode: "restore"

- name: "🔧 Setup Pages"
uses: actions/configure-pages@v5
with:
static_site_generator: next

- name: "🔨 Build projects"
run: yarn build

- name: "📦 Upload artifact"
uses: actions/upload-pages-artifact@v3
with:
path: ./out
deploy:
needs: [ build ]
uses: ./.github/workflows/deploy.yml

release-version:
runs-on: ubuntu-latest
needs: [ version, build ]
needs: [ version, deploy ]
steps:
- name: "🚀 Publish release"
uses: actions/github-script@v7
Expand Down Expand Up @@ -190,17 +97,3 @@ jobs:
reviewers: "codemile"
assignees: "codemile"
draft: false

deploy:
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: [ build, release-version, next-version ]
steps:
- name: "🚀 Deploy to GitHub Pages"
id: deployment
uses: actions/deploy-pages@v4

0 comments on commit 9f00408

Please sign in to comment.