Skip to content

fix

fix #5

Workflow file for this run

name: Build
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: write
pull-requests: write
jobs:
npm-scripts:
name: npm Scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
- name: Bump Version
run: |
APP_VERSION=$(jq -r .version .homeycompose/app.json)
jq ".version=\"$APP_VERSION\"" package.json > package.json.tmp
mv package.json.tmp package.json
- name: 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-
- name: Install Dependencies
run: npm i
- name: Lint and Fix Errors
run: npm run lint:fix
- name: Format Code
run: npm run format:fix
- name: Commit Changes
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "[email protected]"
git add -A
if ! git diff --cached --exit-code; then
git commit -m "Code maintenance: bump version, lint & format"
if [[ ${{ github.ref }} == "refs/heads/main" ]]; then
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
BRANCH_NAME="maintenance-$(date +'%Y%m%d%H%M%S')"
git checkout -b $BRANCH_NAME
git push origin $BRANCH_NAME
gh pr create --base main --head $BRANCH_NAME --title "Maintenance PR" --body "Automatic code maintenance: bump version, lint and format."
gh pr merge --auto --squash ${{ github.event.pull_request.html_url }}
else
git pull origin ${{ github.head_ref }} --rebase
git push origin HEAD:${{ github.head_ref }}
fi
else
echo "No changes to commit."
fi
homey:
name: Homey
needs: npm-scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 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-
- name: Install Dependencies
run: npm ci
- name: Build App # Compile TypeScript
run: |
echo "{}" > app.json
mkdir locales
npm run build
sonarcloud:
name: SonarCloud
needs: npm-scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 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-
- name: Install Dependencies
run: npm ci
- name: Scan Code
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
dependabot:
name: Dependabot
needs: [homey, sonarcloud]
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Fetch Metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Auto-Merge
run: gh pr merge --auto --merge $PR_URL
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}