forked from bcgov/trust-over-ip-configurations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ivan Polchenko <[email protected]>
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Sync Changes to GitOps Repo | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
changed_files: | ||
runs-on: ubuntu-latest | ||
name: Check for file changes | ||
outputs: | ||
any_changed: ${{ steps.gitops-changes.outputs.any_changed }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Scan services directory | ||
id: gitops-changes | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
files: services/*.* | ||
|
||
sync_changes: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- changed_files | ||
if: needs.changed_files.outputs.any_changed == 'true' && (github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch') | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.DITP_GITOPS_REPO_SECRET }} | ||
|
||
- name: Add github.com to known hosts | ||
run: ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
|
||
- name: Checkout GitOps repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: bcgov-c/ministry-gitops-ditp | ||
ssh-key: ${{ secrets.DITP_GITOPS_REPO_SECRET }} | ||
sparse-checkout: | | ||
services | ||
path: ministry-gitops-ditp | ||
|
||
- name: Copy changes | ||
run: | | ||
rsync -avz --delete ./services/ ./ministry-gitops-ditp/services/ | ||
- name: Commit and push changes | ||
run: | | ||
cd ministry-gitops-ditp | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git add . | ||
git commit -m "Sync changes from trust-over-ip-configurations" || echo "No changes to commit" | ||
git push |