Skip to content

Commit

Permalink
ci: migrate from CircleCI to Github Actions (#1836)
Browse files Browse the repository at this point in the history
  • Loading branch information
ze-flo authored Jul 1, 2024
1 parent 44b5263 commit 25b2af7
Show file tree
Hide file tree
Showing 7 changed files with 4,773 additions and 5,458 deletions.
69 changes: 3 additions & 66 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,10 @@ version: 2.1
orbs:
node: circleci/[email protected]

references:
executor: &executor
jobs:
build:
executor:
name: node/default
tag: lts

workspace_root: &workspace_root ~/project

attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root

persist_to_workspace: &persist_to_workspace
persist_to_workspace:
root: *workspace_root
paths: .

jobs:
build:
<<: *executor
steps:
- checkout
- node/install-packages:
override-ci-command: npm ci --ignore-scripts
cache-version: '{{ .Environment.CACHE_VERSION }}'
- run: npm exec -- lerna run build --concurrency=2 # prevent out-of-memory
- *persist_to_workspace

test:
<<: *executor
steps:
- *attach_workspace
- run: npm run test:ci -- --runInBand
- run: '[ $COVERALLS_REPO_TOKEN ] && npm exec -- coveralls < .cache/coverage/lcov.info || true'
- *persist_to_workspace

deploy:
<<: *executor
environment:
NODE_DEBUG: gh-pages
steps:
- *attach_workspace
- run: npm run build:demo
- run: utils/scripts/deploy.mjs

publish:
<<: *executor
steps:
- *attach_workspace
- run: npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
- run: npm exec -- lerna publish from-git --ignore-scripts --yes

workflows:
main:
jobs:
- build
- test:
requires:
- build
- deploy:
requires:
- test
context: writer
- publish:
requires:
- test
context: maintainer
filters:
branches:
only: main
- run: 'true'
149 changes: 149 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: CI

on:
pull_request:

push:
branches:
- main
- next

permissions:
contents: read

jobs:
initialize:
runs-on: ubuntu-latest
outputs:
teams: ${{ steps.get-teams.outputs.teams }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm

- run: npm ci --ignore-scripts
- id: get-teams
run: echo "teams=$(npm exec garden github-teams -- --user ${{ github.triggering_actor }} --token $GH_TOKEN)" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

- run: npm exec -- lerna run build --concurrency=2
- uses: actions/upload-artifact@v4
with:
name: dist-artifact
path: packages/**/dist

lint:
needs: [initialize]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm

- run: npm ci --ignore-scripts
- run: npm run lint:ci

test:
needs: [initialize]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm

- run: npm ci --ignore-scripts
- uses: actions/download-artifact@v4
with:
name: dist-artifact
path: packages

- run: npm run test:ci
- run: npm exec -- coveralls < .cache/coverage/lcov.info
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

deploy-staging:
if: contains(needs.initialize.outputs.teams, 'Writers') && (github.ref != 'refs/heads/main')
needs: [initialize]
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm

- run: npm ci --ignore-scripts
- run: npm run build:demo
- run: utils/scripts/deploy.mjs
env:
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

deploy:
if: contains(needs.initialize.outputs.teams, 'Writers') && (github.ref == 'refs/heads/main')
needs: [initialize, lint, test]
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: 'gh-pages'
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm

- run: npm ci --ignore-scripts
- run: npm run build:demo

- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: './demo'
- id: deployment
uses: actions/deploy-pages@v4

publish:
needs: [initialize, lint, test]
runs-on: ubuntu-latest
if: contains(needs.initialize.outputs.teams, 'Maintainers') && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Lerna requires the full history, including tags

- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
registry-url: https://registry.npmjs.org # Sets the registry in the project level .npmrc

- run: npm ci --ignore-scripts

- uses: actions/download-artifact@v4
with:
name: dist-artifact
path: packages

- run: npm exec -- lerna publish from-git --ignore-scripts --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pull Request Labels
name: PR
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
Expand All @@ -10,4 +10,4 @@ jobs:
with:
mode: exactly
count: 1
labels: "PR: Breaking Change :boom:, PR: Bug Fix :bug:, PR: Docs :memo:, PR: Internal :seedling:, PR: New Feature :rocket:"
labels: 'PR: Breaking Change :boom:, PR: Bug Fix :bug:, PR: Docs :memo:, PR: Internal :seedling:, PR: New Feature :rocket:'
Loading

0 comments on commit 25b2af7

Please sign in to comment.