Skip to content

Commit

Permalink
ci: sync github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
farioas committed Apr 4, 2023
1 parent e1ab86d commit c295153
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/algolia-crawler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Algolia Indexer

on:
push:
branches: [ 'ht/add-new-theme' ]
branches: [ 'develop' ]
paths:
- 'docs/**'
- '.github/workflows/algolia-crawler.yml'
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/cicd_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,28 @@ jobs:
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.fork == false &&
needs.changed_files.outputs.frontend == 'true' &&
needs.changed_files.outputs.commit-message != 'Build frontend'
needs.changed_files.outputs.commit-message != 'ci: Build frontend'
permissions:
contents: write
uses: heartexlabs/label-studio/.github/workflows/frontend-build.yml@develop
with:
ref: ${{ github.event.pull_request.head.ref || github.ref }}

update-feature-flags:
name: "Build"
needs:
- changed_files
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.fork == false &&
needs.changed_files.outputs.commit-message != 'ci: Update Feature Flags'
permissions:
contents: write
uses: heartexlabs/label-studio/.github/workflows/feature-flags-update.yml@develop
with:
ref: ${{ github.event.pull_request.head.ref || github.ref }}
secrets: inherit

build-docker:
name: "Build"
needs:
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/feature-flags-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "Update Feature Flags"

on:
workflow_call:
inputs:
ref:
required: true
type: string
workflow_dispatch:
inputs:
ref:
description: "Ref"
required: true
type: string

env:
LAUNCHDARKLY_DOWNLOAD_PATH: "label_studio/feature_flags.json"
FEATURE_FLAGS_COMMIT_MESSAGE: "ci: Update Feature Flags"

jobs:
commit-feature-flags:
name: "Commit Feature Flags"

runs-on: ubuntu-latest
steps:
- uses: hmarr/[email protected]

- name: Configure git
shell: bash
run: |
set -xeuo pipefail
git config --global user.name 'robot-ci-heartex'
git config --global user.email '[email protected]'
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
ref: ${{ inputs.ref }}

- name: Download feature flags
env:
LAUNCHDARKLY_COMMUNITY_SDK_KEY: ${{ secrets.LAUNCHDARKLY_COMMUNITY_SDK_KEY }}
run: |
set -xeuo pipefail
curl \
--connect-timeout 30 \
--retry 5 \
--retry-delay 10 \
-H "Authorization: $LAUNCHDARKLY_COMMUNITY_SDK_KEY" \
"https://sdk.launchdarkly.com/sdk/latest-all" | jq >"${{ env.LAUNCHDARKLY_DOWNLOAD_PATH }}"
if [ "$(jq 'has("flags")' <<< cat ${{ env.LAUNCHDARKLY_DOWNLOAD_PATH }})" = "true" ]; then
echo "feature_flags.json is valid"
else
echo "feature_flags.json is invalid"
cat ${{ env.LAUNCHDARKLY_DOWNLOAD_PATH }}
exit 1
fi
- name: Commit and Push
run: |
git add "${{ env.LAUNCHDARKLY_DOWNLOAD_PATH }}"
git status -s
git commit -m '${{ env.FEATURE_FLAGS_COMMIT_MESSAGE }}' || true
git push origin HEAD
53 changes: 53 additions & 0 deletions .github/workflows/follow-merge-lsf-sync-schedule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Follow Merge: LSF Sync'

on:
schedule:
- cron: '0 4 * * 1'
workflow_call:
workflow_dispatch:

jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- uses: hmarr/[email protected]

- name: Create dispatch event
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const { repo, owner } = context.repo;
const lsf_owner = 'heartexlabs';
const lsf_repo = 'label-studio-frontend';
const {data: lsf_repo_data} = await github.rest.repos.get({
owner: lsf_owner,
repo: lsf_repo,
});
const {data: lsf_commit} = await github.rest.repos.getCommit({
owner: lsf_owner,
repo: lsf_repo,
ref: lsf_repo_data.default_branch
});
const result = await github.rest.repos.createDispatchEvent({
owner,
repo,
event_type: 'upstream_repo_update',
client_payload: {
branch_name: 'fb-scheduled-lsf-sync',
base_branch_name: lsf_repo_data.default_branch,
repo_name: lsf_repo_data.full_name,
commit_sha: lsf_commit.sha,
title: lsf_commit.commit.message.split('\n')[0],
html_url: lsf_commit.html_url,
actor: lsf_commit.commit.author.name,
author_username: lsf_commit.commit.author.name,
author_email: lsf_commit.commit.author.email,
event_action: 'merged'
}
});
return result
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Sync PR
name: 'Follow Merge: Sync PR'

on:
pull_request_target:
Expand Down
Loading

0 comments on commit c295153

Please sign in to comment.