Skip to content

Commit

Permalink
build: or-1955 refactor to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
koenmetsu committed Oct 18, 2023
1 parent b7adf5e commit 6d28464
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 72 deletions.
16 changes: 16 additions & 0 deletions .github/actions/cache-npm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: cache-npm
description: Cache NPM

runs:
using: 'composite'
steps:

- name: Cache NPM
uses: actions/cache@v3
env:
cache-name: cache-npm
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
20 changes: 20 additions & 0 deletions .github/actions/cache-npm/setup-nodejs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: setup-node
description: Setup nodejs

runs:
using: 'composite'
steps:

- name: Cache NPM
uses: .github/actions/cache-npm

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

- name: Node version
shell: bash
run: node --version

- name: Install NPM dependencies
shell: bash
run: npm install --legacy-peer-deps
37 changes: 37 additions & 0 deletions .github/actions/cache-paket/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: setup-dotnet
description: Setup .NET Core

inputs:
version:
description: 'Required dotnet version'
required: true

runs:
using: 'composite'
steps:

- name: Cache Paket
uses: actions/cache@v3
with:
path: |
.paket/
paket-files/
packages/
key: ${{ runner.os }}-paket-${{ hashFiles('**/paket.lock') }}

- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ inputs.version }}

- name: .NET version
shell: bash
run: dotnet --info

- name: Restore dotnet tools
shell: bash
run: dotnet tool restore

- name: Paket restore
shell: bash
run: dotnet paket restore
16 changes: 16 additions & 0 deletions .github/actions/cache-pip/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: cache-npm
description: Cache NPM

runs:
using: 'composite'
steps:

- name: Cache NPM
uses: actions/cache@v3
env:
cache-name: cache-npm
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
20 changes: 20 additions & 0 deletions .github/actions/setup-nodejs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: setup-node
description: Setup nodejs

runs:
using: 'composite'
steps:

- name: Cache NPM
uses: .github/actions/cache-npm

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

- name: Node version
shell: bash
run: node --version

- name: Install NPM dependencies
shell: bash
run: npm install --legacy-peer-deps
24 changes: 24 additions & 0 deletions .github/actions/setup-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: setup-python
description: Setup Python

runs:
using: 'composite'
steps:

- name: Cache pip
uses: .github/actions/cache-pip

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Python version
shell: bash
run: python --version

- name: Install Python dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install requests markdown argparse
86 changes: 14 additions & 72 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ jobs:
uses: actions/checkout@v3

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

- name: Node version
shell: bash
run: node --version

- name: Install NPM dependencies
shell: bash
run: npm install --legacy-peer-deps
uses: ./.github/actions/setup-nodejs

- name: Generate Token
id: generate_token # Add an ID to this step for reference
Expand Down Expand Up @@ -101,25 +93,14 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v3

- name: Cache NPM
uses: actions/cache@v3
env:
cache-name: cache-npm
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Setup nodejs
uses: ./.github/actions/setup-nodejs

- name: Setup .NET Core
uses: ./.github/actions/setup-dotnet

- name: Cache Paket
uses: actions/cache@v3
env:
cache-name: cache-paket
with:
path: packages
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('paket.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
uses: ./.github/actions/cache-paket

- name: Cache Python
uses: actions/cache@v3
Expand All @@ -133,35 +114,15 @@ jobs:
run: echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") >> $GITHUB_ENV
shell: bash

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

- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ secrets.VBR_DOTNET_VERSION }}

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Node version
shell: bash
run: node --version

- name: .NET version
shell: bash
run: dotnet --info

- name: Python version
shell: bash
run: python --version

- name: Install NPM dependencies
shell: bash
run: npm install --legacy-peer-deps

- name: Install Python dependencies
shell: bash
run: |
Expand Down Expand Up @@ -326,26 +287,8 @@ jobs:
run: echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") >> $GITHUB_ENV
shell: bash

- name: Cache NPM
uses: actions/cache@v3
env:
cache-name: cache-npm
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Setup Node.js
uses: actions/setup-node@v3

- name: Node version
shell: bash
run: node --version

- name: Install NPM dependencies
shell: bash
run: npm install --legacy-peer-deps
- name: Setup nodejs
uses: ./.github/actions/setup-nodejs

- name: Run Semantic Release
shell: bash
Expand Down Expand Up @@ -417,13 +360,12 @@ jobs:
- name: Cache Paket
uses: actions/cache@v3
env:
cache-name: cache-paket
with:
path: packages
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('paket.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
path: |
.paket/
paket-files/
packages/
key: ${{ runner.os }}-paket-${{ hashFiles('**/paket.lock') }}

- name: Publish to Confluence
if: needs.release.outputs.version != 'none'
Expand Down

0 comments on commit 6d28464

Please sign in to comment.