diff --git a/.github/workflows/check_license_and_history.yml b/.github/workflows/check_license_and_history.yml index 319323c0f..21da89dc2 100644 --- a/.github/workflows/check_license_and_history.yml +++ b/.github/workflows/check_license_and_history.yml @@ -1,6 +1,6 @@ name: Check License and History -on: # this workflow is planned to be called by the ci_pipeline and it will compare the PR files with the main +on: workflow_call: workflow_dispatch: push: @@ -17,27 +17,23 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} - name: Get changed files id: changes run: | - echo ${{github.event.pull_request.head.repo.full_name}} - if [ "${{ github.event.pull_request.head.repo.full_name }}" == "speedb-io/speedb" ]; then - echo "files added or changed in a PR that came from the speedb repo: " - git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- . ':!.github' ':!*.md' - echo "diff_list<> $GITHUB_OUTPUT - git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- . ':!.github' ':!*.md' >> $GITHUB_OUTPUT - git diff --name-only --diff-filter=ACMRT remotes/origin/main HEAD -- . ':!.github' ':!*.md' >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - else - echo "added or changed files: " - git diff --name-only --diff-filter=ACMRT remotes/origin/main HEAD -- . ':!.github' ':!*.md' - echo "diff_list<> $GITHUB_OUTPUT - git diff --name-only --diff-filter=ACMRT remotes/origin/main HEAD -- . ':!.github' ':!*.md' >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi + echo "files added or changed in a PR: " + git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- . ':!.github' ':!*.md' + echo "added or changed files: " + git diff --name-only --diff-filter=ACMRT remotes/origin/main HEAD -- . ':!.github' ':!*.md' + echo "diff_list<> $GITHUB_OUTPUT + git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- . ':!.github' ':!*.md' >> $GITHUB_OUTPUT + git diff --name-only --diff-filter=ACMRT remotes/origin/main HEAD -- . ':!.github' ':!*.md' >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + - name: list new files run: | echo "New files in this PR ${{ steps.changes.outputs.diff_list }}" + lint: runs-on: ubuntu-latest needs: changedfiles @@ -48,6 +44,7 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} - name: Check License run: | exit_code=0 @@ -59,7 +56,6 @@ jobs: done exit $exit_code - name: Check HISTORY PR - if: github.event.pull_request.head.repo.full_name == 'speedb-io/speedb' run: | set +e git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}|grep -v "\.github" |grep -q [a-z,A-Z] @@ -91,4 +87,4 @@ jobs: exit $history_not_in fi echo "No files were added" - exit 0 + exit 0 \ No newline at end of file