Skip to content

Commit

Permalink
ci: PLT-478: Replace FM with actions-hub call
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabelonogov committed Sep 3, 2024
1 parent 5c17e6b commit bfd4787
Showing 1 changed file with 11 additions and 50 deletions.
61 changes: 11 additions & 50 deletions .github/workflows/follow-merge-sync-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ concurrency:

env:
DOWNSTREAM_REPOSITORY: "label-studio-enterprise"
DOWNSTREAM_EVENT_TYPE: "upstream_repo_update"

jobs:
sync:
Expand Down Expand Up @@ -60,53 +59,15 @@ jobs:
].join('\n')
});
- name: Sync PR
uses: actions/github-script@v7
if: steps.check-membership.outputs.result == 'true'
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 }}
- name: Checkout Actions Hub
uses: actions/checkout@v4
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
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 }}';
}
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: downstream_repository,
event_type: downstream_event_type,
client_payload: {
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 }}',
actor: '${{ github.actor }}',
author_username: getCommitResponse.data.commit.author.name,
author_email: getCommitResponse.data.commit.author.email,
event_action: event_action
}
});
return result
token: ${{ secrets.GIT_PAT }}
repository: HumanSignal/actions-hub
path: ./.github/actions-hub

- name: Dispatch Follow Merge Event
uses: ./.github/actions-hub/actions/follow-merge-dispatch
with:
github_token: ${{ secrets.GIT_PAT }}
downstream_repository: "${{ env.DOWNSTREAM_REPOSITORY }}"

0 comments on commit bfd4787

Please sign in to comment.