-
Notifications
You must be signed in to change notification settings - Fork 35
76 lines (70 loc) · 2.59 KB
/
graybox-sync-repos.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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: "dc-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/dc-graybox.git ../dc-graybox
cd ../dc-graybox
git checkout $GB_SYNC_BRANCH
echo "dc-graybox branch"
git branch
cd ../dc
echo "dc 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' ./ ../dc-graybox/
- name: Commit and Push Changes to Graybox Repository
run: |
cd ../dc-graybox
echo "dc-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/dc-graybox.git
git remote -v
git add .
git commit -m "Syncing dc to dc-graybox"
git push origin $GB_SYNC_BRANCH --force
echo ":heavy_check_mark: Syncing branch $GB_SYNC_BRANCH on dc to dc-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 }}