Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 51 additions & 15 deletions .github/workflows/update-formplayer-assets.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update Formplayer Assets
name: Build and Commit Formplayer Assets

on:
push:
Expand All @@ -8,31 +8,32 @@ on:
paths:
- 'formulus-formplayer/**'
- '.github/workflows/update-formplayer-assets.yml'
#paths-ignore:
# - 'formulus/android/app/src/main/assets/formplayer_dist/**'
pull_request:
paths:
- 'formulus-formplayer/**'
- '.github/workflows/update-formplayer-assets.yml'
#paths-ignore:
# - 'formulus/android/app/src/main/assets/formplayer_dist/**'

env:
NODE_VERSION: '20'

jobs:
update-assets:
name: Build Formplayer Assets (Validate on PR, Commit on Merge)
build-and-commit-assets:
name: Build and Auto-Commit Formplayer Assets
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
# For PRs, checkout the PR branch (head) so we can commit to it
# PR branches are not protected, so we can push directly
# For pushes, checkout the branch that was pushed to
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down Expand Up @@ -64,20 +65,43 @@ jobs:
path: formulus/android/app/src/main/assets/formplayer_dist
retention-days: 1

- name: Validate assets built successfully (PR only)
- name: Check for asset changes (PR)
if: github.event_name == 'pull_request'
id: check-changes-pr
run: |
git add formulus/android/app/src/main/assets/formplayer_dist
if git diff --cached --quiet; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "No changes to formplayer assets"
else
echo "changed=true" >> $GITHUB_OUTPUT
echo "Formplayer assets have changed"
fi

- name: Commit assets to PR branch
if: steps.check-changes-pr.outputs.changed == 'true' && github.event_name == 'pull_request'
run: |
echo "✅ Committing assets to PR branch: ${{ github.head_ref }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add formulus/android/app/src/main/assets/formplayer_dist
git commit -m "chore: update formplayer assets from formulus-formplayer [skip ci]"
git push
echo "✅ Assets committed to PR branch - will be included when PR is merged"

- name: Validate assets built successfully (PR - no changes)
if: github.event_name == 'pull_request' && steps.check-changes-pr.outputs.changed == 'false'
run: |
if [ ! -d "formulus/android/app/src/main/assets/formplayer_dist" ] || [ -z "$(ls -A formulus/android/app/src/main/assets/formplayer_dist)" ]; then
echo "❌ Formplayer assets were not built successfully"
exit 1
else
echo "✅ Formplayer assets built successfully"
echo "Assets will be committed automatically when PR is merged"
echo "✅ Formplayer assets built successfully (no changes needed)"
fi

- name: Check for asset changes
- name: Check for asset changes (Push)
if: github.event_name == 'push'
id: check-changes
id: check-changes-push
run: |
git add formulus/android/app/src/main/assets/formplayer_dist
if git diff --cached --quiet; then
Expand All @@ -88,12 +112,24 @@ jobs:
echo "Formplayer assets have changed"
fi

- name: Commit and push assets
if: steps.check-changes.outputs.changed == 'true' && github.event_name == 'push'
- name: Commit and push assets (non-protected branches only)
if: steps.check-changes-push.outputs.changed == 'true' && github.event_name == 'push'
run: |
CURRENT_BRANCH="${{ github.ref_name }}"

# Skip committing to protected branches (main/dev) - they require PRs
if [[ "$CURRENT_BRANCH" == "main" ]] || [[ "$CURRENT_BRANCH" == "dev" ]]; then
echo "⚠️ Branch $CURRENT_BRANCH is protected and requires PRs"
echo "Assets have been built and uploaded as artifact"
echo "Note: For protected branches, assets should be committed via PR workflow"
echo "Artifact name: formplayer-assets"
exit 0
fi

# For non-protected branches, commit and push directly
echo "Committing assets to non-protected branch: $CURRENT_BRANCH"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add formulus/android/app/src/main/assets/formplayer_dist
git commit -m "chore: update formplayer assets from formulus-formplayer [skip ci]"
git push

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "./static/css/main.ce996368.css",
"main.js": "./static/js/main.0ff1b14e.js",
"main.js": "./static/js/main.1f0e855c.js",
"index.html": "./index.html",
"main.ce996368.css.map": "./static/css/main.ce996368.css.map",
"main.0ff1b14e.js.map": "./static/js/main.0ff1b14e.js.map"
"main.1f0e855c.js.map": "./static/js/main.1f0e855c.js.map"
},
"entrypoints": [
"static/css/main.ce996368.css",
"static/js/main.0ff1b14e.js"
"static/js/main.1f0e855c.js"
]
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="./logo192.png"/><link rel="manifest" href="./manifest.json"/><title>React App</title><script src="./formulus-load.js"></script><script defer="defer" src="./static/js/main.0ff1b14e.js"></script><link href="./static/css/main.ce996368.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="./logo192.png"/><link rel="manifest" href="./manifest.json"/><title>React App</title><script src="./formulus-load.js"></script><script defer="defer" src="./static/js/main.1f0e855c.js"></script><link href="./static/css/main.ce996368.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.