Skip to content

Commit

Permalink
Merge pull request #92 from vizzuhq/cicd
Browse files Browse the repository at this point in the history
changed: refactor CICD
  • Loading branch information
veghdev authored Dec 14, 2023
2 parents 6900300 + 88b3f37 commit 32cb1a8
Show file tree
Hide file tree
Showing 58 changed files with 4,560 additions and 4,562 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CD

on:
release:
types: [published]
workflow_call:

jobs:
publish:
if: ${{ (github.event_name == 'release' && github.event.action == 'published') }}

runs-on: ubuntu-22.04

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules_ubuntu22_${{ hashFiles('package-lock.json') }}

- name: Get workflow ID
id: workflow_id
run: |
workflow_data=$(curl -s -X GET \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.VIZZUHQ_GITHUB_API }}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows")
workflow_id=$(echo $workflow_data | jq -r '.workflows[] | select(.name == "CI-CD") | .id')
echo "workflow_id=${workflow_id}" >> $GITHUB_OUTPUT
- name: Get run ID
id: run_id
run: |
run_data=$(curl -s -X GET \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.VIZZUHQ_GITHUB_API }}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows/${{ steps.workflow_id.outputs.workflow_id }}/runs?branch=main")
run_id=$(echo $run_data | jq -r '.workflow_runs[0].id')
echo "run_id=${run_id}" >> $GITHUB_OUTPUT
- name: Cache package
uses: actions/cache@v3
with:
path: |
README.md
build/
dist/
key: package_${{ steps.run_id.outputs.run_id }}

- name: Publish package
run: |
npm config set registry=https://registry.npmjs.org/
npm config set //registry.npmjs.org/:_authToken=${NPM_API_TOKEN}
npm publish
env:
NPM_API_TOKEN: ${{ secrets.NPM_API_TOKEN }}

- name: Upload package
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
gh release upload ${{ github.event.release.tag_name }} build/*tgz --clobber
202 changes: 101 additions & 101 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,106 @@
name: CI

on:
workflow_call:
workflow_call:

jobs:
check_src:
runs-on: ubuntu-22.04

env:
PUPPETEER_CACHE_DIR: ${{ github.workspace }}/node_modules/.chromium

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Cache dev-js environment
uses: actions/cache@v3
with:
path: node_modules
key: cache_dev_js_ubuntu22_${{ hashFiles('package-lock.json') }}

- name: Format
run: |
npm run format-src
- name: Lint
run: |
npm run lint-src
- name: Type
run: |
npm run type-src
- name: Test
run: |
npm test
check_docs:
runs-on: ubuntu-22.04

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Cache dev-js environment
uses: actions/cache@v3
with:
path: node_modules
key: cache_dev_js_ubuntu22_${{ hashFiles('package-lock.json') }}

- name: Cache dev-py environment
uses: actions/cache@v3
with:
path: .venv
key: cache_dev_py_ubuntu22_${{ hashFiles('pdm.lock') }}

- name: Format
run: |
source .venv/bin/activate
npm run format-docs
- name: Lint
run: |
source .venv/bin/activate
npm run lint-docs
check_tools:
runs-on: ubuntu-22.04

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Cache dev-js environment
uses: actions/cache@v3
with:
path: node_modules
key: cache_dev_js_ubuntu22_${{ hashFiles('package-lock.json') }}

- name: Cache dev-py environment
uses: actions/cache@v3
with:
path: .venv
key: cache_dev_py_ubuntu22_${{ hashFiles('pdm.lock') }}

- name: Format
run: |
source .venv/bin/activate
npm run format-tools
- name: Lint
run: |
source .venv/bin/activate
npm run lint-tools
- name: Type
run: |
source .venv/bin/activate
npm run type-tools
check_src:
runs-on: ubuntu-22.04

env:
PUPPETEER_CACHE_DIR: ${{ github.workspace }}/node_modules/.chromium

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules_ubuntu22_${{ hashFiles('package-lock.json') }}

- name: Format
run: |
npm run format:src
- name: Lint
run: |
npm run lint:src
- name: Type
run: |
npm run type:src
- name: Test
run: |
npm test
check_docs:
runs-on: ubuntu-22.04

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules_ubuntu22_${{ hashFiles('package-lock.json') }}

- name: Cache venv
uses: actions/cache@v3
with:
path: .venv
key: venv_ubuntu22_${{ hashFiles('pdm.lock') }}

- name: Format
run: |
source .venv/bin/activate
npm run format:docs
- name: Lint
run: |
source .venv/bin/activate
npm run lint:docs
check_tools:
runs-on: ubuntu-22.04

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules_ubuntu22_${{ hashFiles('package-lock.json') }}

- name: Cache venv
uses: actions/cache@v3
with:
path: .venv
key: venv_ubuntu22_${{ hashFiles('pdm.lock') }}

- name: Format
run: |
source .venv/bin/activate
npm run format:tools
- name: Lint
run: |
source .venv/bin/activate
npm run lint:tools
- name: Type
run: |
source .venv/bin/activate
npm run type:tools
32 changes: 16 additions & 16 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: CI-CD

on:
push:
branches: [main]
pull_request:
branches: [main]
push:
branches: [main]
pull_request:
branches: [main]

jobs:
init:
uses: ./.github/workflows/init.yml
init:
uses: ./.github/workflows/init.yml

ci:
uses: ./.github/workflows/ci.yml
needs: init
ci:
uses: ./.github/workflows/ci.yml
needs: init

doc:
uses: ./.github/workflows/doc.yml
needs: ci
doc:
uses: ./.github/workflows/doc.yml
needs: ci

release:
uses: ./.github/workflows/release.yml
secrets: inherit
needs: doc
cd:
uses: ./.github/workflows/cd.yml
secrets: inherit
needs: doc
Loading

0 comments on commit 32cb1a8

Please sign in to comment.