Skip to content

Commit

Permalink
ci: Change ci action
Browse files Browse the repository at this point in the history
  • Loading branch information
klerick committed Feb 28, 2024
1 parent 0203a80 commit ae73539
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/actions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'My composite action'
description: 'Checks out the repository and install'
runs:
using: 'composite'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Restore cached npm dependencies
id: cache-dependencies-restore
uses: actions/cache/restore@v4
with:
path: |
node_modules
~/.cache/Cypress # needed for the Cypress binary
key: ${{ runner.os }}npm-dependencies-${{ hashFiles('package-lock.json') }}
- name: Npm install
run: npm ci
shell: bash
- name: Cache npm dependencies
id: cache-dependencies-save
uses: actions/cache/save@v4
with:
path: |
node_modules
~/.cache/Cypress # needed for the Cypress binary
key: ${{ steps.cache-dependencies-restore.outputs.cache-primary-key }}
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: "master"
52 changes: 52 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Create Releases
on:
workflow_dispatch:

jobs:
build-and-test:
name: "Build and test"
runs-on: ubuntu-latest
permissions:
contents: "read"
actions: "read"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Npm install
uses: ./.github/actions
- run: npx nx affected -t lint test build --parallel=3 --exclude='test-npm' --base=origin/main~1 --head=origin/main
# - run: npm nx affected -t e2e-ci --parallel=1
# - run: npm nx affected -t deploy --no-agents

bump-version:
name: "Bump version"
needs:
- build-and-test
runs-on: ubuntu-latest
permissions:
contents: "write"
actions: "read"
id-token: "write"
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Checkout and install
uses: ./.github/actions
- name: Bump version
run: |
git config user.name 'Alex H'
git config user.email '[email protected]'
npx nx release --skip-publish
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: true
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
jobs:
run-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Npm install
uses: ./.github/actions
# This line is needed for nx affected to work when CI is running on a PR
- run: git branch --track main origin/main
- run: npx nx affected -t lint test build --parallel=3 --exclude='test-npm'
# - run: npm nx affected -t e2e-ci --parallel=1
# - run: npm nx affected -t deploy --no-agents
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish

on:
workflow_run:
workflows: [ "Create Releases" ]
types:
- completed
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
NPM_CONFIG_PROVENANCE: true

jobs:
publish:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Publish
runs-on: ubuntu-latest
permissions:
contents: "read"
actions: "read"
id-token: "write" # needed for provenance data generation
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Npm install
uses: ./.github/actions
- run: npx nx affected -t build --parallel=3 --exclude='test-npm' --base=origin/main~1 --head=origin/main
- name: Publish packages
run: npx nx release publish
shell: bash

0 comments on commit ae73539

Please sign in to comment.