diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b1689cc7..b81487acc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,33 @@ jobs: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" + - name: Initializing git repository + run: | + git init --initial-branch=main + git remote add origin ${{ github.event.repository.html_url }} + + - name: Fetching base and head commit (push) + if: github.event_name == 'push' + env: + PUSHED_COMMITS: ${{ toJSON(github.event.commits) }} + run: | + if [[ ${{ github.event.before }} == 0000000000000000000000000000000000000000 ]] + then + before=$(echo "$PUSHED_COMMITS" | jq .[0].id --raw-output) + + git fetch --no-tags --prune --no-recurse-submodules --depth=2 origin $before ${{ github.event.after }} + + echo "BASE=$(git rev-parse $before~1)" >> $GITHUB_ENV + else + git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin ${{ github.event.before }} ${{ github.event.after }} + + echo "BASE=${{ github.event.before }}" >> $GITHUB_ENV + fi + + echo "HEAD=${{ github.event.after }}" >> $GITHUB_ENV + - name: Fetching base and head commit (pull_request) + if: github.event_name == 'pull_request' run: | git fetch --no-tags --prune --no-recurse-submodules --depth=$((${{ github.event.pull_request.commits }} + 1)) origin ${{ github.event.pull_request.head.sha }} git fetch --no-tags --prune --no-recurse-submodules --depth=10 origin ${{ github.event.pull_request.base.sha }} @@ -32,9 +58,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - with: - fetch-depth: 2 - ref: ${{ github.event.pull_request.head.sha }} - name: Setup node uses: actions/setup-node@v2