ssvc 0.2.1

Implementation of the SSVC specification in Rust
name: Update assets on Dependabot PRs

on:
  workflow_dispatch:
  pull_request_target:
    types: [opened, synchronize]

permissions:
  contents: write
  pull-requests: write

jobs:
  update_assets:
    if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
    runs-on: ubuntu-latest

    steps:
      - name: Check out PR branch
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.ref }}
          token: ${{ secrets.GITHUB_TOKEN }}
          fetch-depth: 0
          submodules: recursive

      - name: Configure Git user
        run: |
          git config user.name  "asset-sync[bot]"
          git config user.email "asset-sync[bot]@users.noreply.github.com"

      - name: Run update_assets.sh
        run: ./update_assets.sh

      - name: Run cargo check (for .rs file re-generation)
        run: cargo check

      - name: Commit changes (if any)
        run: |
          if [[ -n $(git status --porcelain) ]]; then
            git add -A
            git commit -m "chore: sync assets via workflow"
          else
            echo "No changes to commit"
          fi

      - name: Push changes to dependabot branch
        run: git push origin HEAD:${{ github.event.pull_request.head.ref }}