Skip to content
Draft
8 changes: 3 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ jobs:
export SCREENLY_CE_VERSION="0.0.0"
fi

cat src/manifest-${{ matrix.platform }}.json \
| jq --arg version "$SCREENLY_CE_VERSION" '.version = $version' \
> src/manifest.json
jq --arg version "$SCREENLY_CE_VERSION" '.version = $version' src/manifest-${{ matrix.platform }}.json > src/manifest.json

- name: Build Docker images
run: |
Expand All @@ -45,7 +43,7 @@ jobs:
run: |
docker run \
--rm \
-v $(pwd):/app:delegated \
-v "$(pwd):/app:delegated" \
-v /app/node_modules \
sbe_webpack:latest \
/bin/bash -c "npx webpack --config webpack.dev.js && npm run test"
Expand All @@ -55,7 +53,7 @@ jobs:
mkdir artifacts
docker run \
--rm \
-v $(pwd)/artifacts:/app/artifacts:delegated \
-v "$(pwd)/artifacts:/app/artifacts:delegated" \
-v /app/artifacts/node_modules \
sbe_webpack:latest \
/bin/bash -c "npm run build && cp -r dist/ artifacts/"
Expand Down
17 changes: 15 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Run ESLint
name: Run Linters

on:
pull_request:
Expand All @@ -12,7 +12,7 @@ on:
- v*.*

jobs:
build:
eslint:
runs-on: ubuntu-latest
name: Run ESLint
steps:
Expand All @@ -26,3 +26,16 @@ jobs:
- name: Run ESLint
run: |
./bin/run_eslint.sh src/

actionlint:
runs-on: ubuntu-latest
name: Run Linter for GitHub Actions Workflows
strategy:
matrix:
actionlint-version: ['1.7.7']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run actionlint
run: ./bin/run_actionlint.sh
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@

The extension is built using [webpack](https://webpack.js.org/). Please check our [contributing guidelines](CONTRIBUTING.md) for detailed information about opening pull requests and releasing new versions.

### Setup Git Hooks

Before starting development, set up the Git hooks to ensure code quality:

```bash
$ ./bin/install_git_hooks.sh
```

This will install pre-commit hooks that run:
* [actionlint](https://github.com/rhysd/actionlint) - Validates GitHub Actions workflow files
* [ESLint](https://eslint.org/) - Checks JavaScript/TypeScript code quality

### Development Mode

```bash
$ PLATFORM=<PLATFORM> \
VERSION=<VERSION> \
Expand Down
33 changes: 33 additions & 0 deletions bin/install_git_hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -e

HOOK_DIR="$(git rev-parse --git-dir)/hooks"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Create pre-commit hook
cat > "${HOOK_DIR}/pre-commit" << 'EOF'
#!/bin/bash

set -e

# Get the root directory of the git repository
ROOT_DIR=$(git rev-parse --show-toplevel)

# Run actionlint check
echo "Running actionlint check..."
"${ROOT_DIR}/bin/run_actionlint.sh"

# Run eslint check
echo "Running eslint check..."
"${ROOT_DIR}/bin/run_eslint.sh"

# If we got here, all checks passed
exit 0
EOF

# Make the hooks executable
chmod +x "${HOOK_DIR}/pre-commit"
chmod +x "${SCRIPT_DIR}/run_actionlint.sh"

echo "Git hooks installed successfully!"
11 changes: 11 additions & 0 deletions bin/run_actionlint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -euo pipefail

# Run actionlint on the workflows directory
docker run \
--rm \
-v $(pwd):/repo \
--workdir /repo \
rhysd/actionlint:latest \
-color