-
Notifications
You must be signed in to change notification settings - Fork 9
147 lines (136 loc) · 6.65 KB
/
manual.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name : Build Addon - Manual
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment To Deploy Addons'
required: true
type: choice
options:
- none
- production
- staging
- prestaging
- devtesting
- blackpearl
- vikings
- demons
- development
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Set environment variables
run: |
echo "BLACKPEARL_ADDON_URL=https://blackpearl-kibbutz.testsigma.com" >> $GITHUB_ENV
echo "VIKING_ADDON_URL=https://vikings-kibbutz.testsigma.com" >> $GITHUB_ENV
echo "DEMONS_ADDON_URL=https://demons-kibbutz.testsigma.com" >> $GITHUB_ENV
echo "DEVELOPMENT_ADDON_URL=https://development-kibbutz.testsigma.com" >> $GITHUB_ENV
echo "DEVTESTING_ADDON_URL=https://devtesting-kibbutz.testsigma.com" >> $GITHUB_ENV
echo "PRESTAGING_ADDON_URL=https://prestaging-kibbutz.testsigma.com" >> $GITHUB_ENV
echo "STAGING_ADDON_URL=https://staging-kibbutz.testsigma.com" >> $GITHUB_ENV
echo "PROD_ADDON_URL=https://kibbutz.testsigma.com" >> $GITHUB_ENV
echo "GIT_BRANCH=dev" >> $GITHUB_ENV
- name: SSH repo access
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY}}
- name: Setup Java version
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'zulu'
- name: Install xmlstarlet
run: |
sudo apt-get update
sudo apt-get install -y xmlstarlet
- name: Build and commit changes
run: |
echo "Environment value: ${{ github.event.inputs.environment }} "
directories=$(find . -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
echo $directories;
for dir in $directories; do
if [[ $dir != *"."* ]]; then
echo "Setting Variables $dir"
cd $dir
version=$(xmlstarlet sel -t -v "/*[local-name()='project']/*[local-name()='version']" -n pom.xml)
artifactId=$(xmlstarlet sel -t -v "/*[local-name()='project']/*[local-name()='artifactId']" -n pom.xml)
version_dir=build/$version
archival="$artifactId"_source.zip
echo "Building $dir With latest version : $version"
mvn clean install
echo "Archiving the build files to $archival"
zip -r $archival . -x "build/*"
echo "Creating an directory for version : $version_dir"
sudo mkdir -p $version_dir
echo "Copy build files to the location : $version_dir "
sudo mv $archival $version_dir/
sudo cp target/$artifactId.jar target/original-$artifactId.jar $version_dir/
echo "Committing the file changes"
ls $version_dir
echo "Github Actor : ${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
git branch -a
git checkout $GIT_BRANCH
git add .
git commit -m "build files added to the path $version_dir"
git push origin $GIT_BRANCH
cd $version_dir
ENVIRONMENT=${{ github.event.inputs.Environment }}
echo "Updating the $dir addon in stack $ENVIRONMENT"
if [[ "$ENVIRONMENT" == "production"* ]]; then
curl --location --request PUT '${{ env.PROD_ADDON_URL }}/api/v1/plugins' \
--header 'Authorization: Bearer ${{ secrets.PROD_V1_TOKEN }}' \
--form "sourceCode=@\"$archival\"" \
--form 'buildTool="MAVEN"' \
--form 'isDefault="true"'
elif [[ "$ENVIRONMENT" == "staging"* ]]; then
curl --location --request PUT '${{ env.STAGING_ADDON_URL }}/api/v1/plugins' \
--header 'Authorization: Bearer ${{ secrets.STAGING_V1_TOKEN }}' \
--form "sourceCode=@\"$archival\"" \
--form 'buildTool="MAVEN"' \
--form 'isDefault="true"'
elif [[ "$ENVIRONMENT" == "prestaging"* ]]; then
curl --location --request PUT '${{ env.PRESTAGING_ADDON_URL }}/api/v1/plugins' \
--header 'Authorization: Bearer ${{ secrets.PRESTAGING_V1_TOKEN }}' \
--form "sourceCode=@\"$archival\"" \
--form 'buildTool="MAVEN"' \
--form 'isDefault="true"'
elif [[ "$ENVIRONMENT" == "devtesting"* ]]; then
curl --location --request PUT '${{ env.DEVTESTING_ADDON_URL }}/api/v1/plugins' \
--header 'Authorization: Bearer ${{ secrets.DEVTESTING_V1_TOKEN }}' \
--form "sourceCode=@\"$archival\"" \
--form 'buildTool="MAVEN"' \
--form 'isDefault="true"'
elif [[ "$ENVIRONMENT" == "blackpearl"* ]]; then
curl --location --request PUT '${{ env.BLACKPEARL_ADDON_URL }}/api/v1/plugins' \
--header 'Authorization: Bearer ${{ secrets.BLACKPEARL_V1_TOKEN }}' \
--form "sourceCode=@\"$archival\"" \
--form 'buildTool="MAVEN"' \
--form 'isDefault="true"'
elif [[ "$ENVIRONMENT" == "vikings"* ]]; then
curl --location --request PUT '${{ env.VIKING_ADDON_URL }}/api/v1/plugins' \
--header 'Authorization: Bearer ${{ secrets.VIKING_V1_TOKEN }}' \
--form "sourceCode=@\"$archival\"" \
--form 'buildTool="MAVEN"' \
--form 'isDefault="true"'
elif [[ "$ENVIRONMENT" == "demons"* ]]; then
curl --location --request PUT '${{ env.DEMONS_ADDON_URL }}/api/v1/plugins' \
--header 'Authorization: Bearer ${{ secrets.DEMONS_V1_TOKEN }}' \
--form "sourceCode=@\"$archival\"" \
--form 'buildTool="MAVEN"' \
--form 'isDefault="true"'
elif [[ "$ENVIRONMENT" == "development"* ]]; then
curl --location --request PUT '${{ env.DEVELOPMENT_ADDON_URL }}/api/v1/plugins' \
--header 'Authorization: Bearer ${{ secrets.DEVELOPMENT_V1_TOKEN }}' \
--form "sourceCode=@\"$archival\"" \
--form 'buildTool="MAVEN"' \
--form 'isDefault="true"'
fi
cd ../../../
fi
done