Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into fb-lsdv-4864/magic-wand-mig
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-skriabin authored Jan 10, 2024
2 parents 4126a8a + 7e5b044 commit be660d1
Show file tree
Hide file tree
Showing 89 changed files with 4,713 additions and 3,283 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "${{ env.NODE }}"

Expand All @@ -37,7 +37,7 @@ jobs:
run: du -d 0 -h ${{ steps.yarn-cache-dir-path.outputs.dir }}

- name: Install dependencies
run: rm package-lock.json && yarn install
run: yarn install

- run: yarn install
- run: yarn run build:module
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "${{ env.NODE }}"

Expand Down
35 changes: 19 additions & 16 deletions .github/workflows/git-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,40 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Dump the client payload context
env:
PAYLOAD_CONTEXT: ${{ toJson(github.event.client_payload) }}
run: echo "$PAYLOAD_CONTEXT"
- uses: hmarr/[email protected]

- name: Add Workflow link to command comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
- name: Checkout on chat command
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
submodules: 'recursive'
fetch-depth: 0

- name: Configure git
shell: bash
run: |
set -xeuo pipefail
git config --global user.name '${{ github.event.client_payload.github.actor }}'
git config --global user.email '${{ github.event.client_payload.github.actor }}@users.noreply.github.com'
- name: Check for merge conflict
id: check-conflict
env:
SLASH_COMMAND_ARG_BRANCH: ${{ github.event.client_payload.slash_command.args.unnamed.arg2 }}
shell: bash
run: |
set -xeuo pipefail
git config --global user.name '${{ github.event.client_payload.github.actor }}'
git config --global user.email '${{ github.event.client_payload.github.actor }}@users.noreply.github.com'
echo "merge_conflict=$(git merge-tree $(git merge-base HEAD origin/$SLASH_COMMAND_ARG_BRANCH) origin/$SLASH_COMMAND_ARG_BRANCH HEAD | grep '<<')" >> $GITHUB_OUTPUT
- name: Add reaction to command comment on merge conflict
Expand All @@ -46,9 +57,7 @@ jobs:
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> **Error**: Merge conflict detected, please resolve it using the git command line.
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
> **Error**: Merge conflict detected, please resolve it using the command line.
reactions: "-1"

- name: Merge branch into current branch
Expand Down Expand Up @@ -79,8 +88,6 @@ jobs:
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> Already up-to-date. Nothing to commit.
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "confused"

- name: Add reaction to command comment on success
Expand All @@ -93,8 +100,6 @@ jobs:
body: |
> Successfully pushed new changes:
> ${{ steps.commit_and_push.outputs.last_commit_msg }} (${{ steps.commit_and_push.outputs.last_commit_sha }})
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "+1"

- name: Add reaction to command comment on failure
Expand All @@ -106,8 +111,6 @@ jobs:
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> **Error**: failed to execute "${{ github.event.client_payload.slash_command.args.unnamed.arg1 }}" command
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "-1"

help:
Expand Down
103 changes: 103 additions & 0 deletions .github/workflows/jira-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: "/jira command"

on:
repository_dispatch:
types: [ jira-command ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.client_payload.github.payload.issue.number }}-${{ github.event.client_payload.slash_command.command }}-${{ github.event.client_payload.slash_command.args.unnamed.arg1 || github.event.client_payload.slash_command.args.all }}

jobs:
create:
if: ${{ github.event.client_payload.slash_command.args.unnamed.arg1 == 'create' }}
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: hmarr/[email protected]

- name: Add Workflow link to command comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
- name: Check user's membership
uses: actions/github-script@v7
id: check-membership
env:
ACTOR: ${{ github.actor }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const { repo, owner } = context.repo;
const actor = process.env.ACTOR;
const { data: membership } = await github.rest.orgs.getMembershipForUser({
org: owner,
username: actor,
});
if (membership.state != "active") {
const error = `Unfortunately you don't have membership in ${owner} organization, Jira Issue was not created`;
core.setOutput("error", error);
core.setFailed(error);
}
- name: Checkout Actions Hub
uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_PAT }}
repository: HumanSignal/actions-hub
path: ./.github/actions-hub

- name: Jira Create Issue
id: jira-create-issue
uses: ./.github/actions-hub/actions/jira-create-issue
with:
jira_server: ${{ vars.JIRA_SERVER }}
jira_username: ${{ secrets.JIRA_USERNAME }}
jira_token: ${{ secrets.JIRA_TOKEN }}
summary: ${{ github.event.client_payload.github.payload.issue.title }}
description: ${{ github.event.client_payload.github.payload.issue.body }}
project: ${{ github.event.client_payload.slash_command.args.unnamed.arg3 || 'TRIAG' }}
type: ${{ github.event.client_payload.slash_command.args.unnamed.arg2 || 'task' }}

- name: Add reaction to command comment on success
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> Jira issue [${{ steps.jira-create-issue.outputs.key }}](${{ steps.jira-create-issue.outputs.link }}) is created
reactions: "+1"

- name: Add reaction to command comment on failure
uses: peter-evans/create-or-update-comment@v3
if: failure()
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> **Error**: failed to execute "${{ github.event.client_payload.slash_command.args.unnamed.arg1 }}" command
> ${{ steps.check-membership.outputs.error }}
reactions: "-1"

help:
if: github.event.client_payload.slash_command.args.unnamed.arg1 == 'help' || !contains(fromJson('["create"]'), github.event.client_payload.slash_command.args.unnamed.arg1)
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Update comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> Command | Description
> --- | ---
> /jira create [task|bug|story] `PROJECT` | Create a Jira issue in project `PROJECT`
reaction-type: hooray
4 changes: 2 additions & 2 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: hmarr/[email protected]
- uses: thehanimo/pr-title-checker@v1.3.7
- uses: thehanimo/pr-title-checker@v1.4.1
name: "Validate PR's title"
with:
GITHUB_TOKEN: ${{ secrets.GIT_PAT }}
pass_on_octokit_error: false
configuration_path: ".github/pr-title-checker-config.json"
- uses: release-drafter/release-drafter@v5.23.0
- uses: release-drafter/release-drafter@v5.25.0
name: "Set PR's label based on title"
with:
disable-releaser: true
Expand Down
37 changes: 30 additions & 7 deletions .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "/Slash Command Dispatch"
name: Slash Command Dispatch
on:
issue_comment:
types: [created]
Expand All @@ -7,6 +7,10 @@ env:
commands_list: |
help
git
jira
issue_commands_list: |
jira
jobs:
slashCommandDispatch:
Expand All @@ -18,41 +22,60 @@ jobs:

- name: 'Validate command'
id: determine_command
uses: actions/github-script@v6
uses: actions/github-script@v7
env:
COMMANDS_LIST: ${{ env.commands_list }}
ISSUE_COMMANDS_LIST: ${{ env.issue_commands_list }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const body = context.payload.comment.body.toLowerCase().trim()
const commands_list = process.env.COMMANDS_LIST.split("\n")
const issue_commands_list = process.env.ISSUE_COMMANDS_LIST.split("\n")
console.log("Detected PR comment: " + body)
console.log("Commands list: " + commands_list)
console.log("Issue commands list: " + issue_commands_list)
commandArray = body.split(/\s+/)
const contextCommand = commandArray[0].split('/')[1].trim();
console.log("contextCommand: " + contextCommand)
core.setOutput('command_state', 'known')
core.setOutput('is_issue_command', 'false')
if (! commands_list.includes(contextCommand)) {
core.setOutput('command_state', 'unknown')
core.setOutput('command', contextCommand)
}
if (issue_commands_list.includes(contextCommand)) {
core.setOutput('is_issue_command', 'true')
}
- name: Slash Command Dispatch for Issues
id: scd_issues
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command == 'true' }}
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GIT_PAT }}
reaction-token: ${{ secrets.GIT_PAT }}
issue-type: "issue"
reactions: true
commands: ${{ env.issue_commands_list }}

- name: Slash Command Dispatch
id: scd
if: steps.determine_command.outputs.command_state != 'unknown'
- name: Slash Command Dispatch for PRs
id: scd_prs
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command != 'true' }}
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GIT_PAT }}
reaction-token: ${{ secrets.GIT_PAT }}
issue-type: "pull-request"
reactions: true
commands: ${{ env.commands_list }}

- name: Edit comment with error message
if: steps.determine_command.outputs.command_state == 'unknown'
if: ${{ steps.determine_command.outputs.command_state == 'unknown' }}
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
body: |
> '/${{ steps.determine_command.outputs.command }}' is unknown command.
> '/${{ steps.determine_command.outputs.command }}' is an unknown command.
> See '/help'
reactions: eyes, confused
45 changes: 28 additions & 17 deletions .github/workflows/sync-pr-ls.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Sync PR LS
name: 'Follow Merge: Sync PR LSO'

on:
pull_request_target:
Expand All @@ -16,8 +16,8 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}

env:
DOWNSTREAM_REPO_OWNER: heartexlabs
DOWNSTREAM_REPO: label-studio
DOWNSTREAM_REPOSITORY: "label-studio"
DOWNSTREAM_EVENT_TYPE: "upstream_repo_update"

jobs:
sync:
Expand All @@ -28,33 +28,44 @@ jobs:
- uses: hmarr/[email protected]

- name: Sync PR
uses: actions/github-script@v6
uses: actions/github-script@v7
id: sync-pr
env:
TITLE: ${{ github.event.pull_request.title }}
HEAD_REF: ${{ github.head_ref }}
BASE_REF: ${{ github.base_ref }}
PR_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
DOWNSTREAM_REPOSITORY: ${{ env.DOWNSTREAM_REPOSITORY }}
DOWNSTREAM_EVENT_TYPE: ${{ env.DOWNSTREAM_EVENT_TYPE }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const [owner, repo] = '${{ github.event.pull_request.head.repo.full_name || github.repository }}'.split('/');
let event_action = '${{ github.event.action }}'
let commit_sha = '${{ github.event.pull_request.head.sha }}'
const { repo, owner } = context.repo;
const pr_head_repository = process.env.PR_HEAD_REPOSITORY;
const downstream_repository = process.env.DOWNSTREAM_REPOSITORY;
const downstream_event_type = process.env.DOWNSTREAM_EVENT_TYPE;
const [pr_owner, pr_repo] = pr_head_repository.split('/');
const head_ref = process.env.HEAD_REF;
const base_ref = process.env.BASE_REF;
let event_action = '${{ github.event.action }}';
let commit_sha = '${{ github.event.pull_request.head.sha }}';
if (${{ github.event.pull_request.merged }}) {
event_action = 'merged'
commit_sha = '${{ github.sha }}'
event_action = 'merged';
commit_sha = '${{ github.sha }}';
}
const getCommitResponse = await github.rest.repos.getCommit({
owner,
repo,
owner: pr_owner,
repo: pr_repo,
ref: commit_sha
});
const result = await github.rest.repos.createDispatchEvent({
owner: '${{ env.DOWNSTREAM_REPO_OWNER }}',
repo: '${{ env.DOWNSTREAM_REPO }}',
event_type: 'upstream_repo_update',
owner: owner,
repo: downstream_repository,
event_type: downstream_event_type,
client_payload: {
branch_name: '${{ github.head_ref }}',
base_branch_name: '${{ github.base_ref }}',
repo_name: '${{ github.event.pull_request.head.repo.full_name || github.repository }}',
branch_name: head_ref,
base_branch_name: base_ref,
repo_name: '${{ github.repository }}',
commit_sha : commit_sha,
title: process.env.TITLE,
html_url: '${{ github.event.pull_request.html_url }}',
Expand Down
Loading

0 comments on commit be660d1

Please sign in to comment.