Skip to content

Commit

Permalink
Merge pull request #11 from adobecom/stage
Browse files Browse the repository at this point in the history
Sync stage and main
  • Loading branch information
mokimo authored Aug 5, 2024
2 parents b81d320 + 2caea2e commit 69fdf82
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/graybox-sync-repos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Graybox Repo Sync

on:
push:
branches:
- stage
- main
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: "federal-graybox"

- name: Checkout Repo
uses: actions/checkout@v2
with:
persist-credentials: false
ref: ${{ inputs.syncBranch || github.ref_name }}

- name: Clone Graybox Repository and Checkout Stage Branch
run: |
git clone https://github.com/adobecom/federal-graybox.git ../federal-graybox
cd ../federal-graybox
git checkout $GB_SYNC_BRANCH
echo "federal-graybox branch"
git branch
cd ../federal
echo "federal branch"
git branch
env:
GB_SYNC_BRANCH: ${{ inputs.syncBranch || github.ref_name }}

- name: Overwrite graybox 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' ./ ../federal-graybox/
- name: Commit and Push Changes to Graybox Repository
run: |
cd ../federal-graybox
echo "federal-graybox branch"
git branch
git config user.email "$FG_SYNC_BOT_EMAIL"
git config user.name "milo-repo-sync[bot]"
git status
if [[ -n $(git status -s) ]]; then
git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/federal-graybox.git
git remote -v
git add .
git commit -m "Syncing federal to federal-graybox"
git push origin $GB_SYNC_BRANCH --force
echo ":heavy_check_mark: Syncing branch $GB_SYNC_BRANCH on federal to federal-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 || github.ref_name }}
1 change: 1 addition & 0 deletions fstab.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Notes:
#
#
# 1. The URL should be human readable as a path. It should not be a hash.
# 2. Google Drive is no longer allowed for production Adobe projects.

Expand Down

0 comments on commit 69fdf82

Please sign in to comment.