Skip to content

Commit

Permalink
feat: add ci pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanosdev committed Dec 23, 2023
1 parent bc1c9cf commit 2d6798f
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/actions/setup-dfx/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Setup DFX
description: Setup DFX

runs:
using: 'composite'
steps:
- name: Get DFX version
shell: bash
run: echo "dfx_version=$(cat dfx.json | jq -r .dfx)" >> "$GITHUB_ENV"

- name: Setup DFX
uses: dfinity/setup-dfx@main
with:
dfx-version: ${{ env.dfx_version }}

- name: Configure system subnet
shell: bash
run: |
mkdir -p $HOME/.config/dfx
cat <<EOF >$HOME/.config/dfx/networks.json
{
"local": {
"bind": "127.0.0.1:8080",
"type": "ephemeral",
"replica": {
"subnet_type": "system"
}
}
}
EOF
11 changes: 11 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Setup NodeJS
description: Setup NodeJS

runs:
using: 'composite'
steps:
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'
27 changes: 27 additions & 0 deletions .github/actions/setup-pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Setup PNPM
description: Setup PNPM

runs:
using: 'composite'
steps:
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store

- name: Install dependencies
shell: bash
run: pnpm i --frozen-lockfile
32 changes: 32 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build & test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build_and_test:
name: Build & test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- uses: ./.github/actions/setup-node

- uses: ./.github/actions/setup-pnpm

- uses: ./.github/actions/setup-dfx

- name: Start DFX
run: dfx start --background

- name: Build Docs
run: pnpm run -F docs... build

- name: Stop DFX
run: dfx stop
29 changes: 29 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy docs

on: workflow_dispatch

jobs:
deploy_docs:
name: Deploy docs
runs-on: ubuntu-latest
environment:
name: mainnet
url: https://docs.codegov.org
steps:
- name: Checkout Code
uses: actions/checkout@v3

- uses: ./.github/actions/setup-node

- uses: ./.github/actions/setup-pnpm

- uses: ./.github/actions/setup-dfx

- name: Import DFX identity
run: |
echo ${{ secrets.MAINNET_PEM }} > ./mainnet.pem
dfx identity import --ic --storage-mode plaintext mainnet ./mainnet.pem
dfx use mainnet
- name: Deploy docs to mainnet
run: dfx deploy --ic docs
5 changes: 5 additions & 0 deletions canister_ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"docs": {
"ic": "n5otb-3yaaa-aaaal-qcxzq-cai"
}
}

0 comments on commit 2d6798f

Please sign in to comment.