From 40b8a33d42f89548b60d9ae36bcd09a232bc34c6 Mon Sep 17 00:00:00 2001 From: Brandon Marshall Date: Fri, 26 Jul 2024 09:13:06 -0700 Subject: [PATCH 1/2] MWPW-145389 Push sync for floodgate and graybox (#228) --- .github/workflows/fg-sync-repos.yml | 27 +++++++++++++++-------- .github/workflows/graybox-sync-repos.yml | 28 ++++++++++++++++-------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.github/workflows/fg-sync-repos.yml b/.github/workflows/fg-sync-repos.yml index 0d0aa2b..2740183 100644 --- a/.github/workflows/fg-sync-repos.yml +++ b/.github/workflows/fg-sync-repos.yml @@ -1,6 +1,10 @@ name: Floodgate Repo Sync on: + push: + branches: + - stage + - main workflow_dispatch: inputs: syncBranch: @@ -28,7 +32,7 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 with: - ref: ${{ inputs.syncBranch }} + ref: ${{ inputs.syncBranch || github.ref_name }} - name: Clone Floodgate Repository and Checkout Selected Branch run: | @@ -41,7 +45,7 @@ jobs: echo "bacom branch" git branch env: - FG_SYNC_BRANCH: ${{ inputs.syncBranch }} + FG_SYNC_BRANCH: ${{ inputs.syncBranch || github.ref_name }} - name: Overwrite floodgate repo files with latest from source repo run: | @@ -54,14 +58,19 @@ jobs: git branch git config user.email "$FG_SYNC_BOT_EMAIL" git config user.name "$FG_SYNC_BOT_NAME" - git status - git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/bacom-pink.git - git remote -v - git add . - git commit -m "Syncing bacom to bacom-pink" - git push origin $FG_SYNC_BRANCH --force + git status + if [[ -n $(git status -s) ]]; then + git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/bacom-pink.git + git remote -v + git add . + git commit -m "Syncing bacom to bacom-pink" + git push origin $FG_SYNC_BRANCH --force + echo ":heavy_check_mark: Syncing branch $GB_SYNC_BRANCH on bacom to bacom-pink completed successfully." >> $GITHUB_STEP_SUMMARY + else + echo ":heavy_minus_sign: No changes detected on branch $GB_SYNC_BRANCH, nothing to sync." >> $GITHUB_STEP_SUMMARY + fi env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} FG_SYNC_BOT_EMAIL: ${{ secrets.FG_SYNC_BOT_EMAIL }} FG_SYNC_BOT_NAME: ${{ secrets.FG_SYNC_BOT_NAME }} - FG_SYNC_BRANCH: ${{ inputs.syncBranch }} + FG_SYNC_BRANCH: ${{ inputs.syncBranch || github.ref_name }} diff --git a/.github/workflows/graybox-sync-repos.yml b/.github/workflows/graybox-sync-repos.yml index 2717534..6df44fe 100644 --- a/.github/workflows/graybox-sync-repos.yml +++ b/.github/workflows/graybox-sync-repos.yml @@ -1,6 +1,10 @@ name: Graybox Repo Sync on: + push: + branches: + - stage + - main workflow_dispatch: inputs: syncBranch: @@ -10,6 +14,7 @@ on: type: choice options: - 'stage' + - 'main' jobs: build: @@ -28,7 +33,7 @@ jobs: uses: actions/checkout@v2 with: persist-credentials: false - ref: ${{ inputs.syncBranch }} + ref: ${{ inputs.syncBranch || github.ref_name }} - name: Clone Graybox Repository and Checkout Stage Branch run: | @@ -41,7 +46,7 @@ jobs: echo "bacom branch" git branch env: - GB_SYNC_BRANCH: ${{ inputs.syncBranch }} + GB_SYNC_BRANCH: ${{ inputs.syncBranch || github.ref_name }} - name: Overwrite graybox repo files with latest from source repo run: | @@ -54,13 +59,18 @@ jobs: git branch git config user.email "$FG_SYNC_BOT_EMAIL" git config user.name "milo-repo-sync[bot]" - git status - git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/bacom-graybox.git - git remote -v - git add . - git commit -m "Syncing bacom to bacom-graybox" - git push origin $GB_SYNC_BRANCH --force + git status + if [[ -n $(git status -s) ]]; then + git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/bacom-graybox.git + git remote -v + git add . + git commit -m "Syncing bacom to bacom-graybox" + git push origin $GB_SYNC_BRANCH --force + echo ":heavy_check_mark: Syncing branch $GB_SYNC_BRANCH on bacom to bacom-graybox completed successfully." >> $GITHUB_STEP_SUMMARY + else + echo ":heavy_minus_sign: No changes detected on branch $GB_SYNC_BRANCH, nothing to sync." >> $GITHUB_STEP_SUMMARY + fi env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} FG_SYNC_BOT_EMAIL: ${{ secrets.FG_SYNC_BOT_EMAIL }} - GB_SYNC_BRANCH: ${{ inputs.syncBranch }} + GB_SYNC_BRANCH: ${{ inputs.syncBranch || github.ref_name }} From a1656968421cf426f8ba3db807ecb03a96e75066 Mon Sep 17 00:00:00 2001 From: Brandon Marshall Date: Tue, 30 Jul 2024 09:48:22 -0700 Subject: [PATCH 2/2] MWPW-145389 Push sync for floodgate and graybox (#230) --- .github/workflows/fg-sync-repos.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/fg-sync-repos.yml b/.github/workflows/fg-sync-repos.yml index 2740183..8b83b49 100644 --- a/.github/workflows/fg-sync-repos.yml +++ b/.github/workflows/fg-sync-repos.yml @@ -65,9 +65,9 @@ jobs: git add . git commit -m "Syncing bacom to bacom-pink" git push origin $FG_SYNC_BRANCH --force - echo ":heavy_check_mark: Syncing branch $GB_SYNC_BRANCH on bacom to bacom-pink completed successfully." >> $GITHUB_STEP_SUMMARY + echo ":heavy_check_mark: Syncing branch $FG_SYNC_BRANCH on bacom to bacom-pink completed successfully." >> $GITHUB_STEP_SUMMARY else - echo ":heavy_minus_sign: No changes detected on branch $GB_SYNC_BRANCH, nothing to sync." >> $GITHUB_STEP_SUMMARY + echo ":heavy_minus_sign: No changes detected on branch $FG_SYNC_BRANCH, nothing to sync." >> $GITHUB_STEP_SUMMARY fi env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}