Skip to content

Commit

Permalink
ci: fix github release action
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonC committed Jul 7, 2023
1 parent 29a82db commit e1ebcd1
Show file tree
Hide file tree
Showing 5 changed files with 648 additions and 2,015 deletions.
40 changes: 40 additions & 0 deletions .github/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Setup git and nx
description: Set up git and nx for the job

runs:
using: 'composite'
steps:
- name: Prepare repository
shell: bash
run: git fetch --unshallow --prune --tags

- uses: nrwl/nx-set-shas@v3

- name: Unset header
shell: bash
# checkout@v2 adds a header that makes branch protection report errors ):
run: git config --local --unset http.https://github.com/.extraheader

- name: Read .nvmrc
shell: bash
id: nvm
run: echo ::set-output name=nvmrc::$(cat .nvmrc)

- name: Setup Node.js
shell: bash
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.nvmrc }}
cache: npm

- name: Setup branch for NX
shell: bash
run: git branch --track main origin/main

- name: Install without scripts 🔧
shell: bash
run: npm ci --prefer-offline --silent --ignore-scripts

- name: Build 🔨
shell: bash
run: npm run build
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install and Build 🔧
run: |
git branch --track main origin/main
npm ci
npm ci --prefer-offline --silent
npm run build
- name: Deploy 🚀
Expand Down
87 changes: 7 additions & 80 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,71 +12,27 @@ concurrency:
jobs:
setup:
runs-on: ubuntu-latest
outputs:
nvmrc: ${{ steps.nvm.outputs.nvmrc }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2

- name: Read .nvmrc
id: nvm
run: echo ::set-output name=nvmrc::$(cat .nvmrc)
- uses: ./.github/setup

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.nvmrc }}

- name: Setup branch for NX
run: git fetch origin main

- name: Install 🔧
run: npm ci

lint:
checks:
needs: [setup]
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ needs.setup.outputs.nvmrc }}

- name: Setup branch for NX
run: git fetch origin main

- name: Restore npm installs and Lerna setup
run: npm ci
- uses: ./.github/setup

- name: Validate all commits from PR
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

- name: Run linter
run: npm run lint

audit:
needs: [setup]
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ needs.setup.outputs.nvmrc }}

- name: Setup branch for NX
run: git fetch origin main

- name: Restore npm installs and Lerna setup
run: npm ci

- name: Audit Dependencies
run: npm run audit:ci
env:
Expand All @@ -90,16 +46,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ needs.setup.outputs.nvmrc }}

- name: Setup branch for NX
run: git fetch origin main

- name: Restore npm installs and Lerna setup
run: npm ci
- uses: ./.github/setup

- name: Run Tests
run: npm test
Expand All @@ -112,33 +59,13 @@ jobs:

release:
runs-on: ubuntu-latest
needs: [test, audit, lint]
needs: [test, checks]
if: github.head_ref != 'next'
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

- uses: nrwl/nx-set-shas@v3

- name: Read .nvmrc
id: nvm
run: echo ::set-output name=nvmrc::$(cat .nvmrc)

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.nvmrc }}

- name: Setup branch for NX
run: git fetch origin main

- name: Install 🔧
run: npm ci --ignore-scripts

- name: Build
run: npm run build
- uses: ./.github/setup

- name: Create Canary Release ✨
env:
Expand Down
24 changes: 1 addition & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v2

- uses: nrwl/nx-set-shas@v3
- name: Prepare repository
run: git fetch --unshallow --prune --tags

- name: Unset header
# checkout@v2 adds a header that makes branch protection report errors ):
run: git config --local --unset http.https://github.com/.extraheader

- name: Read .nvmrc
id: nvm
run: echo ::set-output name=nvmrc::$(cat .nvmrc)

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.nvmrc }}
cache: npm

- name: Setup branch for NX
run: git branch --track main origin/main

- name: Install 🔧
run: npm ci --ignore-scripts
- uses: ./.github/setup

- name: Build
run: npm run build
Expand Down
Loading

0 comments on commit e1ebcd1

Please sign in to comment.