name: Main Branch Push
on:
  push:
    branches:
      - main
      - master
    paths:
      - 'quickstart/**'
jobs:
  main-branch-push:
    runs-on: ubuntu-latest
    steps:
      - name: get-default-branch
        run: |
          branch=$(curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
          echo "default_branch=$branch" >> $GITHUB_ENV
      - name: checkout
        uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3.6.0
      - uses: 8BitJonny/gh-get-current-pr@2215326c76d51bfa3f2af0a470f32677f6c0cae9 #2.1.0
        id: PR
      - name: Download artifact
        id: download-artifact
        uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e #v2.28.0
        with:
          github_token: ${{secrets.GITHUB_TOKEN}}
          workflow: e2e.yaml
          pr: ${{ steps.PR.outputs.number }}
          name: TestRecord-${{ steps.PR.outputs.number }}
          path: TestRecord
          if_no_artifact_found: ignore
      - name: Update
        run: |
          sh scripts/update-test-record.sh
      - name: Commit & Push changes
        uses: actions-js/push@156f2b10c3aa000c44dbe75ea7018f32ae999772 #v1.4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          message: 'Update TestRecord'
          branch: ${{ env.default_branch }}