Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
[DEVOPS-3298] Converted CircleCI workflow to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
long-wan-ep committed Mar 18, 2022
1 parent c60f3d9 commit 7e921c2
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 24 deletions.
119 changes: 100 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,108 @@
name: CI
name: Lint, build, test, and release the js-sdk

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
pull_request:
types: [opened,reopened]
branches:
- 'main'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
# This job uses skip-duplicate-actions to skip one of the duplicate workflow runs when you push to a branch with an open PR.
check_duplicate_workflow:
needs: []
runs-on: ubuntu-20.04
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v3.4.1
with:
skip_after_successful_duplicate: 'true'
concurrent_skipping: 'same_content_newer'

lint:
needs: [check_duplicate_workflow]
runs-on: ubuntu-20.04
if: ${{ needs.check_duplicate_workflow.outputs.should_skip != 'true' }}
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
cache: 'yarn'
- name: Run lint
run: |
yarn install
yarn run lint
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: [lint]
runs-on: ubuntu-20.04
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
cache: 'yarn'
- name: Build bundles
run: |
yarn install
yarn run rollup
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ github.event.repository.name }}-${{ github.sha }}-${{ github.run_id }}-bundles
path: dist
retention-days: 3

# Steps represent a sequence of tasks that will be executed as part of the job
test:
needs: [build]
runs-on: ubuntu-20.04
env:
MOCHA_FILE: test-results/mocha/test-results.xml
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
cache: 'yarn'
- name: Run tests
run: |
yarn install
yarn run test-output
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: ${{ github.event.repository.name }}-${{ github.sha }}-${{ github.run_id }}-${{ github.job }}-results
path: test-results
retention-days: 3
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v1.27
with:
files: test-results/**/*.xml

release:
needs: [test]
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Trigger CircleCI
env:
CIRCLE_BRANCH: ${{ github.head_ref }}
run: |
curl -X POST \
-H 'Circle-Token: ${CIRCLE_TOKEN}' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d "{\"branch\":\"${CIRCLE_BRANCH}\"}" \
https://circleci.com/api/v2/project/gh/moltin/js-sdk/pipeline
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.10.0'
cache: 'yarn'
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: ${{ github.event.repository.name }}-${{ github.sha }}-${{ github.run_id }}-bundles
- name: Release, publish package
run: |
yarn install
npx semantic-release
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,4 @@ You can learn more about the Rollup API and configuration [here](https://github.
## Terms And Conditions

- Any changes to this project must be reviewed and approved by the repository owner. For more information about contributing, see the [Contribution Guide](https://github.com/moltin/gatsby-demo-store/blob/master/.github/CONTRIBUTING.md).
- For more information about the license, see [MIT License](https://github.com/moltin/js-sdk/blob/master/LICENSE).
- For more information about the license, see [MIT License](https://github.com/moltin/js-sdk/blob/main/LICENSE).
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@moltin/sdk",
"name": "@long-wan-ep/sdk-test",
"description": "SDK for the Moltin eCommerce API",
"version": "0.0.0-semantic-release",
"homepage": "https://github.com/moltin/js-sdk",
"author": "Moltin (https://moltin.com/)",
"homepage": "https://github.com/long-wan-ep/js-sdk",
"author": "Long Wan",
"scripts": {
"commit": "git-cz",
"rollup": "rollup -c",
Expand All @@ -22,7 +22,10 @@
"types": "src/moltin.d.ts",
"repository": {
"type": "git",
"url": "git://github.com/moltin/js-sdk.git"
"url": "git://github.com/long-wan-ep/js-sdk.git"
},
"release": {
"branches": ["main"]
},
"bugs": {
"url": "https://github.com/moltin/js-sdk/issues"
Expand Down

0 comments on commit 7e921c2

Please sign in to comment.