Skip to content

Commit

Permalink
ci: PLT-478: Replace FM with actions-hub call (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabelonogov authored Sep 4, 2024
1 parent fe2d7fd commit e703b6e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 113 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/follow-merge-sync-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: 'Follow Merge: Sync PR LSE'

on:
pull_request_target:
types:
- opened
- closed
- converted_to_draft
- ready_for_review
- synchronize
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}

env:
DOWNSTREAM_REPOSITORY: "label-studio-enterprise"

jobs:
sync:
name: "Sync"
if: startsWith(github.head_ref, 'fb-')
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v3.0.0

- name: Check user's membership
uses: actions/github-script@v7
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@v7
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_REPOSITORY }}.`
].join('\n')
});
- name: Checkout Actions Hub
uses: actions/checkout@v4
with:
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 }}"
113 changes: 0 additions & 113 deletions .github/workflows/sync-pr.yml

This file was deleted.

0 comments on commit e703b6e

Please sign in to comment.