Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout to fork branch when running autoformat bot #5136

Merged
merged 4 commits into from Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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}`,
Copy link
Member Author

@harupy harupy Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is executed on the master branch of mlflow/mlflow so ${owner}/${repo} always returns mlflow/mlflow.

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 }}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github.repository points to a repository where this action is running.

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