on: push: - workflows: [publish-install] filter: branches: [master] paths: ["install.sh"] workflows: publish-install: tasks: - name: publish-install cubes: - name: publish image: alpine:latest env: SC_TOKEN: ${{ secrets.SC_TOKEN }} script: - apk add --no-cache git - | git config user.name "CI Bot" git config user.email "ci@sourcecraft.dev" # Set up authenticated remote - | git remote set-url origin \ "https://ci:${SC_TOKEN}@git.sourcecraft.dev/bigbes/shroud.git" # Create or update the site branch with install.sh - | SITE_BRANCH="site" # Check if site branch exists remotely if git ls-remote --exit-code origin "refs/heads/${SITE_BRANCH}" >/dev/null 2>&1; then git fetch origin "${SITE_BRANCH}" git checkout "${SITE_BRANCH}" else git checkout --orphan "${SITE_BRANCH}" git rm -rf . fi # Copy install.sh from master git show "origin/master:install.sh" > install.sh git add install.sh # Only commit and push if there are changes if git diff --cached --quiet; then echo "No install.sh changes to publish" else git commit -m "site: update install.sh" git push origin "${SITE_BRANCH}" fi