Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Feb 28, 2025
1 parent 532161c commit 91dca1b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 7 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/on-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,3 @@ jobs:
"""
echo "$BODY"
curl -X POST https://slack.com/api/chat.postMessage \
-H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" \
-H 'Content-type: application/json' \
--data "{
'channel': 'C02LU432JGK',
'text': '$BODY'
}"
65 changes: 65 additions & 0 deletions prev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Sync Changes to Farajaland

on:
pull_request:
types:
- closed

jobs:
sync_farajaland:
if: ${{ github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
GH_TOKEN: ${{ secrets.FORK_ORGANISATION_TOKEN }}
FORK_ORGANISATION: ${{ secrets.FORK_REPOSITORY_ORGANISATION }}
FORK_REPOSITORY_NAME: ${{ secrets.FORK_REPOSITORY_NAME }}
FORK_REPOSITORY_PATH: "${{ secrets.FORK_REPOSITORY_ORGANISATION }}/${{ secrets.FORK_REPOSITORY_NAME }}"
steps:
- name: Checkout OpenCRVS Countryconfig repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}

- name: Check if PR branch exists in Farajaland repository
id: check_branch
run: |
if git ls-remote --heads https://${GH_TOKEN}@github.com/${FORK_REPOSITORY_PATH}.git "$BASE_BRANCH" | grep "$BASE_BRANCH"; then
echo "branch_exists=true" >> $GITHUB_ENV
else
echo "=============================================="
echo " 🚀 Branch $BASE_BRANCH doesn't exist in repository ${FORK_REPOSITORY_PATH}"
echo " 🚪 Doing exit"
echo "=============================================="
echo "branch_exists=false" >> $GITHUB_ENV
fi
- name: Sync Farajaland Forkrepository
id: sync_fork
if: env.branch_exists == 'true'
continue-on-error: true
run: |
gh repo sync ${FORK_REPOSITORY_PATH} --branch ${BASE_BRANCH}
- name: Create PR in ${{ secrets.FORK_REPOSITORY_ORGANISATION }}/${{ secrets.FORK_REPOSITORY_NAME }}
if: steps.sync_fork.outcome == 'failure'
continue-on-error: true
run: |
echo "The 'sync_fork' step failed. Creating a PR in ${SYNC_FORK_REPOSITORY_PATH}"
gh pr create \
--repo ${FORK_REPOSITORY_PATH} \
--base ${BASE_BRANCH} \
--head opencrvs:${BASE_BRANCH} \
--title "Update Farajaland from ${BASE_BRANCH}" \
--body \
"""
This PR updates the ${BASE_BRANCH} branch with the latest changes from
the original repository opencrvs:${BASE_BRANCH}.
""" 1>result.txt 2>&1; _res=$?
if [ $? -eq 0 ]; then
printf "PR created successfully: $(grep ${FORK_REPOSITORY_PATH} result.txt)\n"
else
grep ${FORK_REPOSITORY_PATH} result.txt 1>/dev/null &&\
printf "PR already exists: $(grep ${FORK_REPOSITORY_PATH} result.txt)\n" ||\
echo "Failed to create PR"
fi
3 changes: 3 additions & 0 deletions result.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Warning: 2 uncommitted changes
a pull request for branch "opencrvs:main" into branch "main" already exists:
https://github.com/adskyiproger/poc-core-test-my/pull/4

0 comments on commit 91dca1b

Please sign in to comment.