-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (57 loc) · 2.22 KB
/
transform.yaml
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
########
# Usage:
# * Update env.GITOPS_REPO to point to your own Cluster GitOps Repo
# * Create a GitHub Actions secret:
# * Name: GITOPS_PAT
# * Value: A Personal Access Token with the `repo` scope
########
on:
push:
branches: [main]
env:
# TODO: Replace this with your own repository
GITOPS_REPO: renato-marciano/cluster-gitops-rema9
jobs:
transform:
runs-on: ubuntu-latest
steps:
- name: Configure Git
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
git config --global credential.helper store
mkdir -p ~/.config/git
echo "https://git:${{ secrets.GITOPS_PAT }}@github.com/" > ~/.config/git/credentials
- name: Clone Control Plane Repo
uses: actions/checkout@v2
with:
repository: ${{ github.repository }}
path: 'controlplane'
token: ${{ secrets.GITOPS_PAT }}
- name: Clone Cluster GitOps Repo
uses: actions/checkout@v2
with:
repository: ${{ env.GITOPS_REPO }}
path: 'gitops'
token: ${{ secrets.GITOPS_PAT }}
- name: Install transformer
run: npm i -g @multicloud-control-plane/transformer
- name: Transformer - Update Assignments
run: transformer assign ./controlplane
- name: Commit Assignments
id: commit_assignments
run: "cd ./controlplane\nif [ -n \"$(git status --porcelain)\" ]; then \n git add .\n git commit -m \"Updated cluster assignments\"\n git push origin\nelse\n echo \"No new assignments\"\nfi\n\nSHA=$(git rev-parse HEAD)\necho \"::set-output name=SHA::$SHA\"\n"
- name: Transformer - Render templates
run: transformer render ./controlplane ./gitops
- name: Transformer - Update GitOps repo
run: transformer apply ./controlplane ./gitops
- name: Commit GitOps changes
run: |
cd ./gitops
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Update from control plane commit ${{ steps.commit_assignments.outputs.SHA }}"
git push origin main
else
echo "No changes made to cluster gitops repo"
fi