-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (64 loc) · 1.97 KB
/
gitops.yaml
File metadata and controls
64 lines (64 loc) · 1.97 KB
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
name: Sync control plane
permissions:
contents: write
on:
workflow_dispatch:
inputs:
operation:
required: true
description: "Delete, Update or create"
type: string
triggeringUser:
required: true
description: "The email of the triggering user"
type: string
runId:
required: true
description: "Port's Run ID"
type: string
manifest:
required: true
description: "The K8s manifest generated by Port"
type: string
folder:
required: true
description: Folder where the resource will be stored
default: "./infra"
type: string
jobs:
push:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- uses: mikefarah/yq@v4.44.1
- uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{inputs.runId}}
icon: GithubActions
logMessage: "${{ inputs.operation }} manifest ${{ env.PATH }}..."
- name: manifest
run: |
echo '${{ inputs.manifest }}' | yq -p json -o yaml | tee tmp.yaml
kind=$(yq .kind tmp.yaml)
name=$(yq .metadata.name tmp.yaml)
namespace=$(yq .metadata.namespace tmp.yaml)
path=${{ inputs.folder }}/$namespace-$kind-$name.yaml
if [ "${{ inputs.operation }}" = "DELETE" ]; then
rm -f $path
rm -f tmp.yaml
else
mv tmp.yaml $path
fi
- name: Push
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
run: |
git config user.name "GitHub Action"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore: ${{ inputs.operation }} resource by ${{ inputs.triggeringUser }}"
git push