Skip to content

Commit

Permalink
fix: refine github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlking committed May 19, 2024
1 parent 4da0bb2 commit 52fdff1
Show file tree
Hide file tree
Showing 13 changed files with 767 additions and 49 deletions.
9 changes: 9 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Automation

Automating tasks with GitHub Actions

## TODO

### Examples

- https://github.com/kporten/template-react/tree/main/.github/workflows
24 changes: 24 additions & 0 deletions .github/actions/ignore/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Ignore
description: Determine if a workspace has new changes that need to be deployed

inputs:
workspace:
description: Workspace name to check
required: true

outputs:
ignore:
description: Boolean value that indicates if the workspace can be ignored
value: ${{ steps.check.outputs.ignore }}

runs:
using: composite
steps:
- id: check
run: |
if ! pnpm dlx turbo-ignore ${{ inputs.workspace }}; then
echo "ignore=false" >> $GITHUB_OUTPUT
else
echo "ignore=true" >> $GITHUB_OUTPUT
fi
shell: bash
22 changes: 9 additions & 13 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
inputs:
CACHIX_AUTH_TOKEN:
required: true
name: Setup
description: Setup environment and cache

runs:
using: composite
steps:
- name: Install nix
uses: cachix/install-nix-action@v21

- name: Setup cachix
uses: cachix/cachix-action@v12
- uses: pnpm/action-setup@v3
- uses: actions/setup-node@v4
with:
name: gerschtli
authToken: ${{ inputs.CACHIX_AUTH_TOKEN }}

- name: Build dev shell
node-version: lts/*
cache: pnpm
- run: pnpm install
shell: bash
- run: pnpm add --global turbo
shell: bash
run: nix develop --profile profile && rm profile
19 changes: 19 additions & 0 deletions .github/actions/setup/action.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
inputs:
CACHIX_AUTH_TOKEN:
required: true

runs:
using: composite
steps:
- name: Install nix
uses: cachix/install-nix-action@v21

- name: Setup cachix
uses: cachix/cachix-action@v12
with:
name: gerschtli
authToken: ${{ inputs.CACHIX_AUTH_TOKEN }}

- name: Build dev shell
shell: bash
run: nix develop --profile profile && rm profile
64 changes: 29 additions & 35 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,63 +11,57 @@ on:
- 'docs'
- 'infra'
- 'nhost'
pull_request:
branches: [main]
types: [opened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
cog_check:
name: check conventional commit compliance
commit:
name: Check conventional commit compliance
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Conventional commits check
uses: cocogitto/cocogitto-action@v3
with:
check-latest-tag-only: true
# linter:
# name: Lint Code Base
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v4
# with:
# # Full git history is needed to get a proper list of changed files within `super-linter`
# fetch-depth: 0
# - name: Lint Code Base
# uses: github/super-linter@v5
# env:
# VALIDATE_ALL_CODEBASE: false
# IGNORE_GENERATED_FILES: true
# # FILTER_REGEX_EXCLUDE: CHANGELOG.md
# DEFAULT_BRANCH: main
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: Build and Test
# linter:
# name: Lint Code Base
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v4
# with:
# # Full git history is needed to get a proper list of changed files within `super-linter`
# fetch-depth: 0
# - name: Lint Code Base
# uses: github/super-linter@v5
# env:
# VALIDATE_ALL_CODEBASE: false
# IGNORE_GENERATED_FILES: true
# # FILTER_REGEX_EXCLUDE: CHANGELOG.md
# DEFAULT_BRANCH: main
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
check:
name: Check tests pass
timeout-minutes: 15
runs-on: ubuntu-latest
# To use Remote Caching, uncomment the next lines and follow the steps below.
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

steps:
- name: Check out code
- name: 📥 Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2 # for turbo only run tasks for changed workspaces.
- uses: pnpm/action-setup@v3
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'pnpm'
- run: pnpm install
- name: Test with coverage
run: pnpm turbo test:unit:coverage
- name: ⚙️ Setup
uses: ./.github/actions/setup
- name: 🧪 Test coverage
run: turbo test:unit:coverage --filter='[HEAD^1]'
# steps:
# - name: Check out code
# uses: actions/checkout@v4
Expand Down
157 changes: 157 additions & 0 deletions .github/workflows/deployment.yml.todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: Deployment

on:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
versioning:
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changesets.outputs.published }}
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: ⚙️ Setup
uses: ./.github/actions/setup
- name: 📝 Process changesets
uses: changesets/action@v1
id: changesets
with:
title: 'chore: update versions'
commit: 'chore: update versions'
version: pnpm exec changeset version
publish: pnpm exec changeset tag
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

status:
if: needs.versioning.outputs.published == 'true'
needs:
- versioning
runs-on: ubuntu-latest
outputs:
express-ignore: ${{ steps.express.outputs.ignore }}
keystone-ignore: ${{ steps.keystone.outputs.ignore }}
next-ignore: ${{ steps.next.outputs.ignore }}
vite-ignore: ${{ steps.vite.outputs.ignore }}
steps:
- name: 📥 Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: ⚙️ Setup
uses: ./.github/actions/setup
- name: 🪄 Analyze express app
id: express
uses: ./.github/actions/ignore
with:
workspace: express
- name: 🪄 Analyze keystone app
id: keystone
uses: ./.github/actions/ignore
with:
workspace: keystone
- name: 🪄 Analyze next app
id: next
uses: ./.github/actions/ignore
with:
workspace: next
- name: 🪄 Analyze vite app
id: vite
uses: ./.github/actions/ignore
with:
workspace: vite

express:
if: needs.status.outputs.express-ignore == 'false'
needs:
- status
runs-on: ubuntu-latest
env:
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
steps:
- name: 📥 Checkout
uses: actions/checkout@v3
- name: ⚙️ Setup
uses: ./.github/actions/setup
- name: 🏗️ Build
run: turbo build --filter express
# - name: 🚀 Deploy
# run:

keystone:
if: needs.status.outputs.keystone-ignore == 'false'
needs:
- status
runs-on: ubuntu-latest
env:
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
steps:
- name: 📥 Checkout
uses: actions/checkout@v3
- name: ⚙️ Setup
uses: ./.github/actions/setup
- name: 🏗️ Build
run: turbo build --filter keystone
env:
SKIP_ENV_REQUIRED: 1
# - name: 🚀 Deploy
# run:

next:
if: needs.status.outputs.next-ignore == 'false'
needs:
- status
runs-on: ubuntu-latest
env:
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
steps:
- name: 📥 Checkout
uses: actions/checkout@v3
- name: ⚙️ Setup
uses: ./.github/actions/setup
- name: 🏗️ Build
run: turbo build --filter next
# - name: 🚀 Deploy
# run:

vite:
if: needs.status.outputs.vite-ignore == 'false'
needs:
- status
runs-on: ubuntu-latest
env:
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
steps:
- name: 📥 Checkout
uses: actions/checkout@v3
- name: ⚙️ Setup
uses: ./.github/actions/setup
- name: 🏗️ Build
run: turbo build --filter vite
# env:
# VITE_CLERK_PUBLISHABLE_KEY: ${{ vars.VITE_CLERK_PUBLISHABLE_KEY }}
# VITE_SENTRY_DSN: ${{ vars.SENTRY_DSN }}
# VITE_TRPC_URL: ${{ vars.VITE_TRPC_URL }}
# - name: 🚀 Deploy
# uses: actions/upload-artifact@v3
# with:
# name: vite
# path: ./apps/vite/dist
# if-no-files-found: error
# retention-days: 1
2 changes: 1 addition & 1 deletion .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: actions/configure-pages@v5
with:
enablement: true
- name: Setup PNPM 📃
- name: Setup PNPM ⚙️
uses: pnpm/action-setup@v3
- name: Setup Node 📐
uses: actions/setup-node@v4
Expand Down
Loading

0 comments on commit 52fdff1

Please sign in to comment.