Skip to content

Commit

Permalink
Merge pull request #77 from OriginTrail/github-actions
Browse files Browse the repository at this point in the history
Github actions
  • Loading branch information
NZT48 authored May 19, 2023
2 parents fa3cbfa + 3c03387 commit a9e87bf
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: setup

runs:
using: composite
steps:
- name: Setup NodeJS
id: nodejs
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm

- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-node-modules-
- if: steps.cache-node-modules.outputs.cache-hit != 'true'
name: Install dependencies
shell: bash
run: npm ci
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and Commit

on:
pull_request:
branches:
- main

jobs:
build-and-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up environment
uses: ./.github/actions/setup

- name: Run build
run: npm run build

- name: Commit and push if it changed
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
message="Automated build commit
Co-authored-by: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
git diff --quiet && git diff --staged --quiet || git commit -m "$message"
git push
33 changes: 33 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: npm-publish

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up environment
uses: ./.github/actions/setup

- name: Run linter
run: npm run lint

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up environment
uses: ./.github/actions/setup

- name: Publish npm package
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
22 changes: 22 additions & 0 deletions .github/workflows/update-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: update-cache

on:
push:
branches:
- main

concurrency:
group: update-cache-${{ github.ref }}
cancel-in-progress: true

jobs:
build-cache:
name: Build Cache
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up environment
uses: ./.github/actions/setup

0 comments on commit a9e87bf

Please sign in to comment.