forked from mosip/mosip-helm
-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (94 loc) · 3.79 KB
/
push_trigger.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Publish mosip-helm charts
on:
push:
branches:
- 1.2.0.*
- develop
- govstack*
jobs:
Generate_Documentation:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Checkout Repository
uses: actions/checkout@v2
#if: github.event.inputs.git-ref != ''
#with:
# ref: ${{ github.event.inputs.git-ref }}
- name: Setup Branch and Env
run: |
# Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
echo "COMMIT_ID=${GITHUB_SHA}" >> $GITHUB_ENV
- id: files
uses: jitterbit/get-changed-files@v1
- name: save helm/charts to tmp.txt file
run: |
touch ./tmp.txt
for changed_file in ${{ steps.files.outputs.all }}; do
echo "File: ${changed_file}."
if [[ $changed_file =~ ^[charts] ]]; then
echo "${changed_file}" | awk -F '/' '/^[charts]/{print $2}' >> ./tmp.txt;
echo "Saved $( echo ${changed_file} | awk -F '/' '/^[charts]/{print $2}') chart to tmp.txt"
fi
done
cat tmp.txt | sort | uniq > ./tmp1.txt
mv ./tmp1.txt ./tmp.txt
echo "List of charts to be published";
cat ./tmp.txt
- name: Generate tar files
run: |
echo "BRANCH_NAME=$BRANCH_NAME";
helm repo add mosip https://tf-govstack.github.io/mosip-helm
echo "COMMIT=${{ env.COMMIT_ID }}"
echo "SKIP=FALSE" >> $GITHUB_ENV
if [[ ! -s ./tmp.txt ]]; then
echo "No Charts to publish";
echo "SKIP=TRUE" >> $GITHUB_ENV
fi
#cd charts &&
#find * -prune -type d > ../tmp.txt
#cd ..
while IFS= read -r line
do
fullpath=$line
echo "Pullpath: $fullpath"
fullname=$(basename "$line")
echo "Filename: $fullname"
helm dependency update charts/$fullpath/
helm package charts/$fullpath
done < tmp.txt
- name: Upload tar as Artifact
uses: actions/upload-artifact@v2
with:
name: charts
path: ./*.tgz
retention-days: 1
if: env.SKIP != 'TRUE'
- name: Checkout branch for publishing
uses: actions/checkout@v2
with:
ref: gh-pages
if: env.SKIP != 'TRUE'
- name: Download tar from Artifacts
uses: actions/download-artifact@v2
with:
name: charts
path: ./
if: env.SKIP != 'TRUE'
- name: Update index.yaml
run: |
git status
helm repo index --url https://tf-govstack.github.io/mosip-helm/ .
if: env.SKIP != 'TRUE'
- name: Commit Changes to mosip-helm Repository
uses: EndBug/add-and-commit@v7
with:
branch: gh-pages
default_author: github_actions
message: 'added helm charts for release ${{ github.event.inputs.git-ref }}'
add: './*.tgz ./index.yaml'
if: env.SKIP != 'TRUE'