This commit is contained in:
Lost Paul 2025-01-31 13:17:14 +01:00
commit e3e51062fa

View file

@ -0,0 +1,70 @@
name: Build and Push to Folder Overview
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
tag:
description: "Tag to build"
required: true
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout folder-notes
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Use tag from input if triggered manually
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "GITHUB_REF=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
fi
- name: Run fv-build
run: |
npm install
npm run fv-build
- name: Checkout folder-overview repository
uses: actions/checkout@v3
with:
repository: LostPaul/obsidian-folder-overview
token: ${{ secrets.PAT }}
path: folder-overview
- name: Initialize and update submodule for folder-overview
run: |
cd folder-overview
git submodule update --init --recursive
- name: Copy built files from folder-notes to folder-overview
run: |
# Make sure the built files exist and copy them
if [ -f "src/obsidian-folder-overview/main.js" ] && [ -f "src/obsidian-folder-overview/styles.css" ]; then
cp src/obsidian-folder-overview/main.js src/obsidian-folder-overview/styles.css folder-overview/
else
echo "Built files not found, exiting"
exit 1
fi
- name: Commit and push built files to folder-overview
run: |
cd folder-overview
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -f main.js styles.css # Add the files inside folder-overview
git commit -m "Add built files for release"
git push origin main # Push to main branch or correct branch
- name: Trigger release workflow in folder-overview
run: |
curl -X POST -H "Authorization: token ${{ secrets.PAT }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/LostPaul/obsidian-folder-overview/actions/workflows/release.yml/dispatches \
-d '{"ref": "main", "inputs": {"tag": "${{ github.ref_name }}", "branch": "auto-build-${{ github.ref_name }}"}}'