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

fix: DIA-554: [FE] Sometimes only a subset of Dataset tasks are displ… #713

fix: DIA-554: [FE] Sometimes only a subset of Dataset tasks are displ…

fix: DIA-554: [FE] Sometimes only a subset of Dataset tasks are displ… #713

Workflow file for this run

name: Sync PR LSE
on:
pull_request_target:
types:
- opened
- closed
- converted_to_draft
- ready_for_review
- synchronize
branches:
- master
- 'lse-release/**'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
env:
DOWNSTREAM_REPO: label-studio-enterprise
jobs:
sync:
name: "Sync"
if: startsWith(github.head_ref, 'fb-')
runs-on: ubuntu-latest
steps:
- uses: hmarr/[email protected]
- name: Check user's membership
uses: actions/github-script@v6
id: check-membership
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const { repo, owner } = context.repo;
try {
return (await github.rest.orgs.getMembershipForUser({
org: owner,
username: '${{ github.actor }}',
}))?.data?.state == "active";
} catch (error) {
return false;
}
- name: Notify user on failure
if: steps.check-membership.outputs.result == 'false'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const { repo, owner } = context.repo;
const result = await github.rest.issues.createComment({
owner,
repo,
issue_number: '${{ github.event.number }}',
body: [
'Hi @${{ github.actor }}!',
'',
`Unfortunately you don't have membership in ${owner} organization, your PR wasn't synced with ${owner}/${{ env.DOWNSTREAM_REPO }}.`
].join('\n')
});
- name: Sync PR
uses: actions/github-script@v6
if: steps.check-membership.outputs.result == 'true'
id: sync-pr
env:
TITLE: ${{ github.event.pull_request.title }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const { repo, owner } = context.repo;
const [pr_owner, pr_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 }}'
if (${{ github.event.pull_request.merged }}) {
event_action = 'merged'
commit_sha = '${{ github.sha }}'
}
const getCommitResponse = await github.rest.repos.getCommit({
owner: pr_owner,
repo: pr_repo,
ref: commit_sha
});
const result = await github.rest.repos.createDispatchEvent({
owner: owner,
repo: '${{ env.DOWNSTREAM_REPO }}',
event_type: 'upstream_repo_update',
client_payload: {
branch_name: '${{ github.head_ref }}',
base_branch_name: '${{ github.base_ref }}',
repo_name: '${{ github.repository }}',
commit_sha : commit_sha,
title: process.env.TITLE,
html_url: '${{ github.event.pull_request.html_url }}',
actor: '${{ github.actor }}',
author_username: getCommitResponse.data.commit.author.name,
author_email: getCommitResponse.data.commit.author.email,
event_action: event_action
}
});
return result