CI/CD #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
env: | |
PACKAGE_MANAGER: bun | |
VERSION_FILE: packages/nuxt/package.json | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: write | |
id-token: write | |
jobs: | |
check-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
src: ${{ steps.changes.outputs.src }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: | | |
src: | |
- 'packages/**/package.json' | |
- 'packages/**/*.lockb' | |
- 'packages/**/src/**' | |
- 'package.json' | |
- 'bun.lockb' | |
build-and-test: | |
runs-on: ubuntu-latest | |
needs: check-changes | |
if: needs.check-changes.outputs.src == 'true' || github.event_name == 'workflow_dispatch' | |
outputs: | |
version_changed: ${{ steps.version_check.outputs.has_changed }} | |
env: | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: ⚙️ Setup ${{ env.PACKAGE_MANAGER }} | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: 📦 Install Dependencies | |
run: ${{ env.PACKAGE_MANAGER }} install | |
- name: 🚀 Project Setup | |
run: ${{ env.PACKAGE_MANAGER }} run dev:prepare | |
- name: 🧪 Lint and Build | |
run: | | |
${{ env.PACKAGE_MANAGER }} run lint | |
${{ env.PACKAGE_MANAGER }} run build | |
- name: 🔍 Check Version Changes | |
uses: HugoRCD/[email protected] | |
id: version_check | |
with: | |
path: ${{ env.VERSION_FILE }} | |
deploy: | |
needs: build-and-test | |
strategy: | |
matrix: | |
include: | |
- name: main | |
script: release.sh | |
branch: main | |
- name: ui | |
script: release-ui.sh | |
branch: main | |
if: | | |
needs.build-and-test.outputs.version_changed == 'true' || | |
github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: ⚙️ Setup ${{ env.PACKAGE_MANAGER }} | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: 🚀 Deploy ${{ matrix.name }} | |
run: ./scripts/${{ matrix.script }} | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |