diff --git a/.github/workflows/autoformat.js b/.github/workflows/autoformat.js index ca76af3d415fd..e4051a8cf76da 100644 --- a/.github/workflows/autoformat.js +++ b/.github/workflows/autoformat.js @@ -13,14 +13,21 @@ const createCommitStatus = async (context, github, sha, state) => { }); }; -const createStatus = async (context, github) => { +const createStatus = async (context, github, core) => { const { owner, repo } = context.repo; const pull_number = context.issue.number; const pr = await github.pulls.get({ owner, repo, pull_number }); - const { sha, ref } = pr.data.head; + const { + sha, + ref, + repo: { full_name }, + } = pr.data.head; await createCommitStatus(context, github, sha, 'pending'); + if (full_name === 'mlflow/mlflow' && ref === 'master') { + core.setFailed('Running autoformat bot against master branch of mlflow/mlflow is not allowed.'); + } return { - repository: `${owner}/${repo}`, + repository: full_name, pull_number, sha, ref, diff --git a/.github/workflows/autoformat.yml b/.github/workflows/autoformat.yml index a70407c0a1dab..609bf6489137d 100644 --- a/.github/workflows/autoformat.yml +++ b/.github/workflows/autoformat.yml @@ -36,7 +36,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const autoformat = require('./.github/workflows/autoformat.js'); - return await autoformat.createStatus(context, github); + return await autoformat.createStatus(context, github, core); check-diff: runs-on: ubuntu-latest @@ -55,7 +55,7 @@ jobs: - name: Check diff id: check-diff run: | - repository="${{ needs.check-comment.outputs.repository }}" + repository="${{ github.repository }}" pull_number="${{ needs.check-comment.outputs.pull_number }}" changed_files="$(python dev/list_changed_files.py --repository $repository --pr-num $pull_number)" py_changed=$([[ -z $(echo "$changed_files" | grep '\.py$') ]] && echo "false" || echo "true")