Skip to content

Commit

Permalink
Add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tung-Huynh-Shopmacher committed Jul 18, 2024
1 parent ea01b2a commit d6e534a
Show file tree
Hide file tree
Showing 4 changed files with 917 additions and 861 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
branches:
- main
- develop
pull_request:
branches:
- "**"

jobs:
yarn-check:
runs-on: ubuntu-latest

defaults:
run:
working-directory: processor

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Install dependencies
run: npm ci

- name: ESLint check
run: npm run lint

- name: Prettier check
run: npm run prettier:check

- name: Build project
run: npm run build

- name: Run tests
run: npm run test

- name: Run audit
run: npm audit
54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish

on:
push:
tags:
# Release tags v1.0.0, v1.0.1, v1.0.2, etc.
- 'v[0-9]+.[0-9]+.[0-9]+'
# Pre-release tags v1.0.0-alpha.0, v1.0.0-beta.0, etc.
- 'v[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+'
- latest
workflow_dispatch:

jobs:
publish:
name: Publish for commercetools Checkout
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install
env:
CTP_CLIENT_ID: ${{ secrets.CTP_CLIENT_ID }}
CTP_CLIENT_SECRET: ${{ secrets.CTP_CLIENT_SECRET }}
CTP_CONNECTOR_KEY: ${{ secrets.CTP_CONNECTOR_KEY }}
CTP_REGION: ${{ secrets.CTP_REGION }}
run: |
echo Updating connector to tag $GITHUB_REF_NAME
echo Authenticating with commercetools
OAUTH_RESPONSE=$(curl --silent --show-error --location --request POST "https://auth.$CTP_REGION.commercetools.com/oauth/token?grant_type=client_credentials" -u $CTP_CLIENT_ID:$CTP_CLIENT_SECRET)
ACCESS_TOKEN=$(echo $OAUTH_RESPONSE | jq -r '.access_token')
echo Access token retrieved
CONNECTOR_DETAILS=$(curl --silent --show-error --location "https://connect.$CTP_REGION.commercetools.com/connectors/drafts/key=$CTP_CONNECTOR_KEY" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $ACCESS_TOKEN")
VERSION=$(echo $CONNECTOR_DETAILS | jq -r '.version')
echo Updating version $VERSION
curl --fail-with-body --silent --location POST "https://connect.$CTP_REGION.commercetools.com/connectors/drafts/key=$CTP_CONNECTOR_KEY" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--data-raw "{\"version\": $VERSION, \"actions\": [{\"action\": \"setRepository\",\"url\": \"[email protected]:mollie/commercetools-connector.git\",\"tag\": \"$GITHUB_REF_NAME\"},{\"action\": \"updatePreviewable\"}]}"
20 changes: 11 additions & 9 deletions processor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d6e534a

Please sign in to comment.