Skip to content

Commit

Permalink
CCI to GHA migration
Browse files Browse the repository at this point in the history
This merge sunsets the CircleCI deployment workflow and replaces it with a GHA workflow.
  • Loading branch information
skripted-io authored Oct 24, 2023
2 parents 135b4dc + d958545 commit b00bf28
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 65 deletions.
129 changes: 64 additions & 65 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,69 @@
# version: 2.1
# orbs:
# commitlint: conventional-changelog/[email protected]
# node: circleci/[email protected]

version: 2.1
orbs:
commitlint: conventional-changelog/[email protected]
node: circleci/[email protected]
# jobs:
# build-and-test:
# executor:
# name: node/default
# resource_class: medium
# tag: '16.19'
# steps:
# - checkout
# - node/install-packages
# - run: npm run build
# - run: npm run test
# - persist_to_workspace:
# root: ~/project
# paths:
# - .
# deploy:
# executor:
# name: node/default
# resource_class: medium
# tag: '16.19'
# steps:
# - attach_workspace:
# at: ~/project
# - run: npm run semantic-release

jobs:
build-and-test:
executor:
name: node/default
resource_class: medium
tag: '16.19'
steps:
- checkout
- node/install-packages
- run: npm run build
- run: npm run test
- persist_to_workspace:
root: ~/project
paths:
- .
deploy:
executor:
name: node/default
resource_class: medium
tag: '16.19'
steps:
- attach_workspace:
at: ~/project
- run: npm run semantic-release
# workflows:
# commitlint:
# when:
# not:
# or:
# - equal: [ master, <<pipeline.git.branch>> ]
# - equal: [ develop, <<pipeline.git.branch>> ]
# - matches: { pattern: "^hotfix.*", value: <<pipeline.git.branch>> }
# - matches: { pattern: "^release.*", value: <<pipeline.git.branch>> }
# jobs:
# - commitlint/lint:
# target-branch: develop

workflows:
commitlint:
when:
not:
or:
- equal: [ master, <<pipeline.git.branch>> ]
- equal: [ develop, <<pipeline.git.branch>> ]
- matches: { pattern: "^hotfix.*", value: <<pipeline.git.branch>> }
- matches: { pattern: "^release.*", value: <<pipeline.git.branch>> }
jobs:
- commitlint/lint:
target-branch: develop
# build-and-test-workflow:
# when:
# not:
# or:
# - equal: [ master, <<pipeline.git.branch>> ]
# - equal: [ develop, <<pipeline.git.branch>> ]
# - matches: { pattern: "^hotfix.*", value: <<pipeline.git.branch>> }
# - matches: { pattern: "^release.*", value: <<pipeline.git.branch>> }
# jobs:
# - build-and-test

build-and-test-workflow:
when:
not:
or:
- equal: [ master, <<pipeline.git.branch>> ]
- equal: [ develop, <<pipeline.git.branch>> ]
- matches: { pattern: "^hotfix.*", value: <<pipeline.git.branch>> }
- matches: { pattern: "^release.*", value: <<pipeline.git.branch>> }
jobs:
- build-and-test
# deploy-workflow:
# when:
# or:
# - equal: [ master, <<pipeline.git.branch>> ]
# - equal: [ develop, <<pipeline.git.branch>> ]
# - matches: { pattern: "^hotfix.*", value: <<pipeline.git.branch>> }
# - matches: { pattern: "^release.*", value: <<pipeline.git.branch>> }

deploy-workflow:
when:
or:
- equal: [ master, <<pipeline.git.branch>> ]
- equal: [ develop, <<pipeline.git.branch>> ]
- matches: { pattern: "^hotfix.*", value: <<pipeline.git.branch>> }
- matches: { pattern: "^release.*", value: <<pipeline.git.branch>> }

jobs:
- build-and-test
- deploy:
context:
- scratch-npm-creds
requires:
- build-and-test
# jobs:
# - build-and-test
# - deploy:
# context:
# - scratch-npm-creds
# requires:
# - build-and-test
1 change: 1 addition & 0 deletions .github/CODEOWNERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@scratchfoundation/scratch-engineering
53 changes: 53 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI/CD

on:
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
pull_request: # Runs whenever a pull request is created or updated
push: # Runs whenever a commit is pushed to the repository
branches: [master, develop, hotfix/*, release]

concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

permissions:
contents: write # publish a GitHub release
pages: write # deploy to GitHub Pages
issues: write # comment on released issues
pull-requests: write # comment on released pull requests

jobs:
ci-cd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: wagoid/commitlint-github-action@v5
if: github.event_name == 'pull_request'

- uses: actions/setup-node@v3
with:
cache: "npm"
node-version-file: ".nvmrc"

- name: Info
run: |
cat <<EOF
Node version: $(node --version)
NPM version: $(npm --version)
GitHub ref: ${{ github.ref }}
GitHub head ref: ${{ github.head_ref }}
EOF
- name: Setup & Test
run: |
npm ci
npm run build
npm run test
- name: Semantic release (configured to run dry if branch is other than 'develop')
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx --no -- semantic-release
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16

0 comments on commit b00bf28

Please sign in to comment.