Skip to content

Commit

Permalink
refactor github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Dec 16, 2024
1 parent aba3f7c commit c380ec6
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name: 'Build'

on:
push:
pull_request:
Expand All @@ -16,7 +14,6 @@ jobs:
npm run test:ci
npm run build
dependabot:
name: 'Dependabot'
needs: [build]
runs-on: ubuntu-latest
permissions:
Expand Down
60 changes: 6 additions & 54 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,17 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches:
on: push

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
languages: javascript
- uses: github/codeql-action/autobuild@v3
- uses: github/codeql-action/analyze@v3
37 changes: 5 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: Release

on:
push:
tags:
- '*'

jobs:
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -22,48 +19,24 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build the file
- name: Build
run: |
cd /home/runner/work/custom-sonos-card/custom-sonos-card
npm install
npm run build
sh create-dist-maxi-media-player.sh
- name: Create Release
- name: Create Release (Sonos)
uses: softprops/action-gh-release@v2
with:
body: ${{steps.build_changelog.outputs.changelog}}
prerelease: true
files: /home/runner/work/custom-sonos-card/custom-sonos-card/dist/custom-sonos-card.js
files: "${GITHUB_WORKSPACE}/dist/custom-sonos-card.js"

- name: Create Release
- name: Create Release (Mxmp)
uses: softprops/action-gh-release@v2
with:
body: ${{steps.build_changelog.outputs.changelog}}
repository: punxaphil/maxi-media-player
prerelease: true
token: ${{ secrets.PAT_TOKEN }}
files: /home/runner/work/custom-sonos-card/custom-sonos-card/dist-maxi-media-player/maxi-media-player.js

- uses: actions/checkout@v4
with:
repository: punxaphil/maxi-media-player
token: ${{ secrets.PAT_TOKEN }}
path: mxmp
files: "${GITHUB_WORKSPACE}/dist-maxi-media-player/maxi-media-player.js"

- name: setup git config
run: |
cd mxmp
cp ../dist-maxi-media-player/README.md .
rm -rf img
mkdir img
cp ../img/* img/
diff=$(git diff)
if [ ! -z "$diff" ]
then
git config user.name "Johan Frick"
git config user.email "[email protected]"
git commit -am"updated README.md"
git push origin main
fi
38 changes: 38 additions & 0 deletions .github/workflows/sync-with-mxmp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build
run: |
npm install
npm run build
- uses: actions/checkout@v4
with:
repository: punxaphil/maxi-media-player
token: ${{ secrets.PAT_TOKEN }}
path: mxmp

- name: Update MXMP repository
run: |
cd mxmp
cp ../dist-maxi-media-player/README.md .
rm -rf img
mkdir img
cp ../img/* img/
diff=$(git diff)
if [ ! -z "$diff" ]
then
git config user.name "Johan Frick"
git config user.email "[email protected]"
git commit -am"updated README.md"
git push origin main
fi
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ The above YAML renders the following:

![styling.png](https://github.com/punxaphil/custom-sonos-card/raw/main/img/styling.png)

<!-- //#ONLY_SONOS_CARD_START -->
### More card_mod examples

### Example 1 - Reduce margin for grouping list items
Expand Down Expand Up @@ -675,4 +674,4 @@ card_mod:
}
```
![img.png](https://github.com/punxaphil/custom-sonos-card/raw/main/img/card_mod_4.png)
<!-- //#ONLY_SONOS_CARD_END -->
6 changes: 6 additions & 0 deletions create-dist-maxi-media-player.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ DIR="dist-maxi-media-player"
FILE="maxi-media-player.js"
mkdir -p $DIR

# Use gsed on Mac
if [[ "$OSTYPE" == "darwin"* ]]; then
alias sed=gsed
fi

cp dist/custom-sonos-card.js $DIR/$FILE
cd $DIR || exit
sed -i 's/"sonos-card"/"maxi-media-player"/g' $FILE
Expand All @@ -22,3 +27,4 @@ sed -i ':a;N;$!ba;s/[^\n]*#ONLY_SONOS_CARD[^\n]*\n//g' $FILE
sed -i 's/custom-sonos-card/maxi-media-player/g' $FILE
sed -i 's/custom:sonos-card/custom:maxi-media-player/g' $FILE
sed -i 's/Sonos Card/Maxi Media Player/g' $FILE
sed -i 's/sonos-/mxmp-/g' $FILE
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"vitest": "^2.1.3"
},
"scripts": {
"build": "npm run lint -- --fix && vite build",
"build": "npm run lint -- --fix && vite build && sh create-dist-maxi-media-player.sh",
"local-deploy": "npm run build && cp dist/custom-sonos-card.js ~/homeassistant/www/community/custom-sonos-card/custom-sonos-card.js",
"lint": "eslint src test",
"test": "vitest",
Expand Down

0 comments on commit c380ec6

Please sign in to comment.