|
| 1 | +name: Publish ST Schemas |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'st-schemas/**' |
| 9 | + |
| 10 | +jobs: |
| 11 | + publish-schemas: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Configure Git |
| 21 | + run: | |
| 22 | + git config --global user.name 'github-actions[bot]' |
| 23 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 24 | +
|
| 25 | + - name: Create or switch to st-schemas branch |
| 26 | + run: | |
| 27 | + # Check if st-schemas branch exists |
| 28 | + if git show-ref --verify --quiet refs/heads/st-schemas; then |
| 29 | + git checkout st-schemas |
| 30 | + git reset --hard origin/main |
| 31 | + else |
| 32 | + git checkout -b st-schemas |
| 33 | + fi |
| 34 | +
|
| 35 | + - name: Prepare st-schemas branch |
| 36 | + run: | |
| 37 | + # Remove all files and directories except st-schemas |
| 38 | + find . -maxdepth 1 ! -name '.' ! -name '..' ! -name '.git' ! -name 'st-schemas' -exec rm -rf {} + |
| 39 | +
|
| 40 | + # Move contents of st-schemas to root |
| 41 | + mv st-schemas/* ./ |
| 42 | + rmdir st-schemas |
| 43 | +
|
| 44 | + # Remove any remaining hidden files/directories except .git |
| 45 | + find . -maxdepth 1 -name '.*' ! -name '.git' -exec rm -rf {} + 2>/dev/null || true |
| 46 | +
|
| 47 | + - name: Commit and push changes |
| 48 | + run: | |
| 49 | + # Check if there are changes to commit |
| 50 | + if [[ -n $(git status --porcelain) ]]; then |
| 51 | + git add . |
| 52 | + git commit -m "Update ST schemas from main branch |
| 53 | +
|
| 54 | + This commit contains the latest schemas from the st-schemas directory. |
| 55 | + Auto-generated by GitHub Actions." |
| 56 | + git push origin st-schemas --force |
| 57 | + else |
| 58 | + echo "No changes to commit" |
| 59 | + fi |
0 commit comments