Skip to content

Commit

Permalink
Update deployment workflow to include build and deploy steps (#40)
Browse files Browse the repository at this point in the history
* chore: Update deployment workflow to include build and deploy steps

* chore: Update deployment workflow to include build and deploy steps

* chore: Remove unnecessary required flag in workflow inputs

* chore: Refactor deployment workflows to remove unnecessary install step

* chore: Update node version to 20 and cache yarn in build workflow

* chore: Add success step to pull_request workflow

This commit adds a new step called "success" to the pull_request workflow. This step runs on the ubuntu-latest runner and is triggered after the "build" step. The purpose of this step is to echo a success message and output a variable called "success" with the value "true". This step is designed to trigger auto merge if all dependencies are met.
  • Loading branch information
codemile authored Jun 1, 2024
1 parent e2f47e8 commit e7576b6
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 198 deletions.
52 changes: 45 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
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?"
type: boolean
default: false

concurrency: "build"

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

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

- name: "📦 Install dependencies"
uses: reactgular/cache@v1
with:
Expand All @@ -28,6 +42,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 +64,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 +86,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 +103,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

70 changes: 70 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "🚀 Deploy"

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

concurrency: "deploy"

jobs:
build:
uses: ./.github/workflows/build.yml
with:
testOnly: true

artifacts:
runs-on: ubuntu-latest
needs: [ build ]
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"
run: yarn build

- name: "📦 Upload artifact"
uses: actions/upload-pages-artifact@v3
with:
path: ./out

deploy:
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: [ artifacts ]
if: ${{ github.event.inputs.skipDeploy == false }}
steps:
- name: "🚀 Deploy to GitHub Pages"
id: deployment
uses: actions/deploy-pages@v4
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "🚀 Main"

on:
push:
branches:
- main
workflow_dispatch:

concurrency: "main"

jobs:
build:
uses: ./.github/workflows/build.yml
77 changes: 8 additions & 69 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,75 +9,14 @@ concurrency:
cancel-in-progress: true

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

- name: "📦 Install dependencies"
uses: reactgular/cache@v1
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:
uses: ./.github/workflows/build.yml

success:
runs-on: ubuntu-latest
needs: [ install ]
needs: [ build]
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
- name: "✅ Success"
run: echo "::notice title={Success}::This step triggers auto merge if all dependencies are met."
outputs:
success: "true"
Loading

0 comments on commit e7576b6

Please sign in to comment.