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

[DEVOPS-3298] Converted CircleCI workflow to GitHub Actions #601

Merged
merged 9 commits into from
Apr 22, 2022
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
96 changes: 0 additions & 96 deletions .circleci/config.yml

This file was deleted.

120 changes: 101 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,109 @@
name: CI
name: CI/CD for 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'
- 'beta'

# 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 lint

build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: [check_duplicate_workflow]
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 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: [check_duplicate_workflow]
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 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: [lint, build, test]
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta') }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELASTICPATH }}
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).
pa-eps marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"type": "git",
"url": "git://github.com/moltin/js-sdk.git"
pa-eps marked this conversation as resolved.
Show resolved Hide resolved
},
"release": {
"branches": ["main", "beta"]
},
"bugs": {
"url": "https://github.com/moltin/js-sdk/issues"
},
Expand Down