Skip to content

Commit

Permalink
chore: enterprise-repo-sync.yaml (#3127)
Browse files Browse the repository at this point in the history
* added enterprise-repo-sync.yaml

* updated enterprise-repo-sync.yaml to fill the body with git comment

* Update enterprise-repo-sync.yaml

---------

Co-authored-by: Prakarsh <71125043+prakarsh-dt@users.noreply.github.com>
  • Loading branch information
pawan-59 and prakarsh-dt authored Mar 21, 2023
1 parent 8b3626d commit 7af703e
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/enterprise-repo-sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: ent-repo-sync

# Controls when the workflow will run
on:
push:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
sync:
runs-on: ubuntu-latest
steps:
- run: |
export GIT_USERNAME="${GIT_CONFIG_NAME}"
export GIT_PASSWORD="${GH_TOKEN}"
export ENTERPRISE_REPO="https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/devtron-labs/devtron-enterprise.git"
git clone https://github.com/devtron-labs/devtron
git clone $ENTERPRISE_REPO
cd devtron && export GIT_COMMIT_ID=`git log --format="%H" -n 1`
export GIT_COMMIT=${GIT_COMMIT_ID:0:8}
echo $GIT_COMMIT
git config --global user.email $GIT_CONFIG_EMAIL
git config --global user.name $GIT_USERNAME
git status && git checkout main && git pull
cd ../devtron-enterprise && git status && git checkout main && git pull
git remote add oss-devtron ../devtron && git remote -v && git remote update && git merge oss-devtron/main
export WIRE_GEN_FILE_NAME="wire_gen.go"
export CONFLICT_FILES=`git diff --name-only --diff-filter=U --relative`
if [[ $WIRE_GEN_FILE_NAME = $CONFLICT_FILES ]]
then
rm $WIRE_GEN_FILE_NAME
docker container run -w /devtron -v ./:/devtron golang /bin/sh -c "go install github.com/google/wire/cmd/wire@latest && wire"
git add $WIRE_GEN_FILE_NAME
elif [[ $CONFLICT_FILES != "" ]]
then
echo "more conflict files"
exit 1
fi
git commit -m "OSS main synced" && git status
git checkout -b oss-enterprise-sync-$GIT_COMMIT && git push -u origin oss-enterprise-sync-$GIT_COMMIT
PR_RESPONSE=$(gh pr create --title "SYNC: OSS sync for $GIT_COMMIT" --fill --base main --head oss-enterprise-sync-$GIT_COMMIT --repo $ENTERPRISE_REPO)
echo "FINAL PR RESPONSE: $PR_RESPONSE"
env:
GH_TOKEN: ${{ secrets.GIT_TOKEN }}
GIT_CONFIG_NAME: ${{ secrets.GIT_TARGET_USERNAME }}
GIT_CONFIG_EMAIL: ${{ secrets.GIT_TARGET_EMAIL }}

0 comments on commit 7af703e

Please sign in to comment.