Skip to content

Workflow file for this run

name: Headlamp plugin linting, type checking, and testing
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
HEADLAMP_PLUGIN_VERSION: latest
jobs:
# Get list of folders containing headlamp plugins
# We need a separate step to be able to pass the list to the matrix of the build job
find_plugin_dirs:
runs-on: ubuntu-latest
outputs:
dirs: ${{ steps.dirs.outputs.dirs }}
steps:
- uses: actions/checkout@v2
- id: dirs
run: echo "dirs=$(grep -m1 -lR @kinvolk/headlamp-plugin ./*/package.json | xargs -n1 dirname | jq --raw-input --slurp --compact-output 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT}
build:
needs: find_plugin_dirs
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
working-directory: ./
strategy:
matrix:
node-version: [18.x]
dir: ${{ fromJson(needs.find_plugin_dirs.outputs.dirs) }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: |
echo "Checking ${{ matrix.dir }} plugin"
npx @kinvolk/headlamp-plugin@$HEADLAMP_PLUGIN_VERSION format --check ${{ matrix.dir }}
npx @kinvolk/headlamp-plugin@$HEADLAMP_PLUGIN_VERSION lint ${{ matrix.dir }}
npx @kinvolk/headlamp-plugin@$HEADLAMP_PLUGIN_VERSION build ${{ matrix.dir }}
npx @kinvolk/headlamp-plugin@$HEADLAMP_PLUGIN_VERSION test ${{ matrix.dir }}
npx @kinvolk/headlamp-plugin@$HEADLAMP_PLUGIN_VERSION tsc ${{ matrix.dir }}
- env:
GH_TOKEN: ${{ github.token }}
if: github.ref == 'refs/heads/master'
run: |
name=$(jq -r .name ${{ matrix.dir }}/package.json)
version=$(jq -r .version ${{ matrix.dir }}/package.json)
tag_name="${name}-${version}"
if ! git rev-parse "$tag_name" >/dev/null 2>&1; then
ls -l ${{ matrix.dir }}/dist
gh release create "$tag_name" ${{ matrix.dir }}/dist/* --title "Release $tag_name" --notes "Release $tag_name"
fi