Skip to content

Commit

Permalink
Checkout to fork branch when running autoformat bot (#5136)
Browse files Browse the repository at this point in the history
* checkout to fork

Signed-off-by: harupy <hkawamura0130@gmail.com>

* validation

Signed-off-by: harupy <hkawamura0130@gmail.com>

* pass core

Signed-off-by: harupy <hkawamura0130@gmail.com>

* fix

Signed-off-by: harupy <hkawamura0130@gmail.com>
  • Loading branch information
harupy committed Dec 2, 2021
1 parent cb873ab commit 1ac1f3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/autoformat.js
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/autoformat.yml
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 1ac1f3a

Please sign in to comment.