Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHA migration #422

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading