Files
dynamics-userscripts/.gitea/workflows/publish.yml
T
matt.rb b05ef16265
Publish userscripts / publish (push) Waiting to run
Add publish workflow
2026-10-25 13:36:23 +10:00

41 lines
1.3 KiB
YAML

name: Publish userscripts
on:
push:
branches: [main]
paths:
- 'src/**'
- '.gitea/workflows/**'
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build dist
run: |
VERSION=$(TZ=AEST-10 date +%Y.%m.%d.%H%M)
BASE=https://code.home-brightview.com/matt.rb/dynamics-userscripts/raw/branch/dist
mkdir -p dist
for f in src/*.user.js; do
n=$(basename "$f" .user.js)
sed -e "s|^// @version .*|// @version $VERSION|" \
-e "s|^// ==/UserScript==|// @updateURL $BASE/$n.meta.js\n// @downloadURL $BASE/$n.user.js\n// ==/UserScript==|" \
"$f" > "dist/$n.user.js"
sed -n '1,/==\/UserScript==/p' "dist/$n.user.js" > "dist/$n.meta.js"
echo "Built $n $VERSION"
done
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Force-push dist branch
env:
TOKEN: ${{ secrets.PUBLISH_TOKEN }}
run: |
cd dist
git init -b dist
git config user.name "gitea-actions"
git config user.email "actions@home-brightview.com"
git add .
git commit -m "Publish $VERSION"
git push -f "https://matt.rb:${TOKEN}@git.home-brightview.com/${{ github.repository }}.git" dist