Skip to content

Commit

Permalink
MWPW-146524: Repo Sync Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sukamat committed Jun 6, 2024
1 parent e031888 commit 622a22c
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/fg-sync-repos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Floodgate Repo Sync

on:
workflow_dispatch:
inputs:
syncBranch:
description: 'Branch to sync'
required: true
default: 'stage'
type: choice
options:
- 'stage'
- 'main'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.FG_SYNC_APP_ID }}
private-key: ${{ secrets.FG_SYNC_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: "bacom-blog-pink"

- name: Checkout Repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.syncBranch }}

- name: Clone Floodgate Repository and Checkout Selected Branch
run: |
git clone https://github.com/adobecom/bacom-blog-pink.git ../bacom-blog-pink
cd ../bacom-blog-pink
git checkout $FG_SYNC_BRANCH
echo "bacom-blog-pink branch"
git branch
cd ../bacom-blog
echo "bacom-blog branch"
git branch
env:
FG_SYNC_BRANCH: ${{ inputs.syncBranch }}

- name: Overwrite floodgate repo files with latest from source repo
run: |
rsync -av --exclude='fstab.yaml' --exclude='.github' --exclude='.kodiak' --exclude='.git' --exclude='.idea' --exclude='.husky' --exclude='.vscode' --exclude='tools/sidekick/config.json' ./ ../bacom-blog-pink/
- name: Commit and Push Changes to Floodgate Repository
run: |
cd ../bacom-blog-pink
echo "bacom-blog-pink branch"
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:[email protected]/adobecom/bacom-blog-pink.git
git remote -v
git add .
git commit -m "Syncing bacom-blog to bacom-blog-pink"
git push origin $FG_SYNC_BRANCH --force
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 }}

0 comments on commit 622a22c

Please sign in to comment.