diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index aaa592f1cf08..013c7a8f4995 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -19,29 +19,27 @@ on: PIPELINE_GITHUB_APP_PRIVATE_KEY: required: false +env: + GIT_AUTHOR_EMAIL: "packages@datadoghq.com" + GIT_AUTHOR_NAME: "ci.datadog-api-spec" + jobs: pre-commit: runs-on: ubuntu-latest steps: - name: Get GitHub App token - if: inputs.enable-commit-changes && github.event.pull_request.head.repo.full_name == github.repository id: get_token + if: inputs.enable-commit-changes uses: actions/create-github-app-token@v1 with: app-id: ${{ secrets.PIPELINE_GITHUB_APP_ID }} private-key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} - uses: actions/checkout@v3 - if: github.event.pull_request.head.repo.full_name == github.repository with: fetch-depth: 0 repository: DataDog/datadog-api-client-typescript ref: ${{ inputs.target-branch || github.event.pull_request.head.sha || github.ref }} token: ${{ inputs.enable-commit-changes && steps.get_token.outputs.token || github.token }} - - uses: actions/checkout@v3 - if: github.event.pull_request.head.repo.full_name != github.repository - with: - repository: DataDog/datadog-api-client-typescript - ref: ${{ inputs.target-branch || github.ref }} - uses: actions/setup-python@v4 with: python-version: '3.11' @@ -69,7 +67,7 @@ jobs: FROM_REF: ${{ steps.commit_range.outputs.from_ref }} TO_REF: ${{ steps.commit_range.outputs.to_ref }} - name: Commit changes - if: failure() && inputs.enable-commit-changes && github.event.pull_request.head.repo.full_name == github.repository + if: ${{ failure() && inputs.enable-commit-changes }} run: |- git add -A git config user.name "${GIT_AUTHOR_NAME}" @@ -79,8 +77,6 @@ jobs: exit 1 env: HEAD_REF: ${{ github.event.pull_request.head.ref }} - GIT_AUTHOR_EMAIL: "packages@datadoghq.com" - GIT_AUTHOR_NAME: "ci.datadog-api-spec" - id: pre_commit_schedule name: Run pre-commit in schedule if: github.event_name == 'schedule'