-
Notifications
You must be signed in to change notification settings - Fork 2
92 lines (89 loc) · 3.22 KB
/
add-sa.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# This is a workflow that is manually triggered
name: adding a serviceaccount
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
name:
# Friendly description to be shown in the UI instead of 'name'
description: 'a name for new resource, in this case, for ServiceAccount'
# Default value if no value is explicitly provided
default: 'this-new-sa'
# Input has to be provided for the workflow to run
required: true
source-branch:
description: 'a source branch where the new branch will come from'
default: 'main'
required: true
new-branch:
description: 'new branch name'
default: 'feature/new-sa'
required: true
draft:
description: 'wether to make the PR draft or not'
default: 'yes'
required: true
jobs:
add-sa:
runs-on: ubuntu-latest
env:
sa_name: "${{ github.event.inputs.name }}"
steps:
- name: Checkout
uses: actions/[email protected]
with:
ref: '${{ github.event.inputs.source-branch }}'
- name: Create New Branch
run: git checkout -b '${{ github.event.inputs.new-branch }}'
- name: build docker image to run the meat
working-directory: .github/actions/run
run: make build
# unfortunately act use its own naming for the image so this is required
# otherwise act will not build again for new updated source code when the image already exists
- name: build docker image to run the meat
# but only if it's running by act
if: ${{ env.ACT }}
working-directory: .github/actions/run
run: make build-for-act
- name: mkdir
run: |
mkdir -p kustomize/crossplane/resources/mock-cloud/serviceaccounts
- name: add serviceaccount
uses: ./.github/actions/run
with:
run: >-
cd kustomize/crossplane/resources/mock-cloud
&&
../../../.templates/add-sa.sh "serviceaccounts/${{ env.sa_name }}.yaml" "${{ env.sa_name }}"
- name: kustomize build
uses: ./.github/actions/run
with:
run: >-
cd kustomize/crossplane/resources/mock-cloud
&&
kustomize build
- name: commit and push
uses: github-actions-x/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'update example.yaml'
push-branch: '${{ github.event.inputs.new-branch }}'
name: friendly-bot
- name: determine draft
id: draft-truefalse
run: |
result_in_truefalse="false"
test "${{ github.event.inputs.draft }}" == "yes" && result_in_truefalse="true"
echo -n "::set-output name=draft::"
echo "${result_in_truefalse}"
- name: File Pull Request
uses: repo-sync/pull-request@master
with:
source_branch: '${{ github.event.inputs.new-branch }}'
destination_branch: '${{ github.event.inputs.source-branch }}'
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "New ServiceAccount for ${{ env.sa_name }}"
pr_body: ":crown: *An automated PR*"
pr_draft: ${{ steps.draft-truefalse.outputs.draft }}