forked from oracle/weblogic-azure
-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (146 loc) · 6.34 KB
/
newtag.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: New Tag
on:
workflow_dispatch:
inputs:
tagname:
description: 'Specify Tag name to create/update.'
required: true
default: '2021-12-10-01-Q4'
ref:
description: 'Specify Git Ref if needed.'
required: false
default: 'refs/heads/main'
repository_dispatch:
types: [gh-pages-newtag]
# sample cURL
# curl --verbose -X POST https://api.github.com/repos/<github_user>/weblogic-azure/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -H 'Authorization: token <personal_access_token>' --data '<request_data>'
# sample <request_data>
# {"event_type": "gh-pages-newtag, "client_payload": {"tagname": "2021-12-09-02-Q4" }}
env:
tagbranch: "tagbranch"
gitToken: ${{ secrets.GIT_TOKEN }}
refArmttk: d97aa57d259e2fc8562e11501b1cf902265129d9
refJavaee: 13fe6ec487024eb61355d661ab5700ae90cb0a8f
repoName: "weblogic-azure"
userEmail: ${{ secrets.USER_EMAIL }}
userName: ${{ secrets.USER_NAME }}
jobs:
newtag:
runs-on: ubuntu-latest
steps:
- name: Setup environment variables
id: setup-env-variables-based-on-dispatch-event
run: |
if [ ${{ github.event_name }} == 'workflow_dispatch' ]; then
tagname=${{ github.event.inputs.tagname }}
ref=${{ github.event.inputs.ref }}
else
tagname=${{ github.event.client_payload.tagname }}
ref=${{ github.event.client_payload.ref }}
fi
echo "##[set-output name=tagname;]${tagname}"
echo "##[set-output name=ref;]${ref}"
echo "tagname=${tagname}" >> $GITHUB_ENV
echo "ref=${ref}" >> $GITHUB_ENV
- name: Checkout ${{ env.repoName }}
uses: actions/checkout@v2
with:
path: ${{ env.repoName }}
ref: ${{ github.event.inputs.ref }}
- name: Checkout azure-javaee-iaas
uses: actions/checkout@v2
with:
repository: Azure/azure-javaee-iaas
path: azure-javaee-iaas
ref: ${{ env.refJavaee }}
- name: Checkout arm-ttk
uses: actions/checkout@v2
with:
repository: Azure/arm-ttk
path: arm-ttk
ref: ${{ env.refArmttk }}
- name: Set up bicep
run: |
curl -Lo bicep https://github.com/Azure/bicep/releases/download/v0.4.613/bicep-linux-x64
chmod +x ./bicep
sudo mv ./bicep /usr/local/bin/bicep
bicep --version
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build azure-javaee-iaas
run: mvn -DskipTests clean install --file azure-javaee-iaas/pom.xml
- name: Build ${{ env.repoName }}
run: |
cd ${{ env.repoName }}
mvn -Ptemplate-validation-tests clean install --file weblogic-azure-vm/arm-oraclelinux-wls/pom.xml
mvn -Ptemplate-validation-tests clean install --file weblogic-azure-vm/arm-oraclelinux-wls-admin/pom.xml
mvn -Ptemplate-validation-tests clean install --file weblogic-azure-vm/arm-oraclelinux-wls-cluster/pom.xml
mvn -Ptemplate-validation-tests clean install --file weblogic-azure-vm/arm-oraclelinux-wls-dynamic-cluster/pom.xml
echo "build bicep files"
bicep build weblogic-azure-aks/src/main/bicep/mainTemplate.bicep --outfile weblogic-azure-aks/src/main/arm/mainTemplate.json
bicep build weblogic-azure-aks/src/main/bicep/modules/setupDBConnection.bicep --outfile weblogic-azure-aks/src/main/arm/dbTemplate.json
bicep build weblogic-azure-aks/src/main/bicep/modules/updateWebLogicApplications.bicep --outfile weblogic-azure-aks/src/main/arm/updateAppTemplate.json
- name: Create new tag
run: |
cd ${{ env.repoName }}
git config --global core.longpaths true
git config --global user.email $userEmail
git config --global user.name $userName
authGitPath=https://$gitToken@github.com/${GITHUB_REPOSITORY}.git
echo "Create tag branch"
remoteBranches=$(git ls-remote --heads)
echo ${remoteBranches}
if [[ -n `echo ${remoteBranches} | grep "${tagbranch}"` ]]; then
git push ${authGitPath} --delete ${tagbranch} -f
fi
if [[ -n `git branch --all | grep "${tagbranch}"` ]]; then
git branch -D ${tagbranch}
fi
git checkout -b ${tagbranch}
# replace pids
export targetARM="target"
for d in weblogic-azure-vm/*/ ; do
# for admin offer and single node offer
if [ -d ${d}${targetARM} ];then
list=$(find ${d}${targetARM} | grep ".json")
for file in ${list}; do
sourcePath=$(echo "$file" | sed "s:target:src/main:g")
if test -f "$sourcePath"; then
echo "Replace ${sourcePath} with ${file}"
cp -f $file $sourcePath
fi
done
fi
for d1 in $d*/; do
if [ ! -d ${d1}${targetARM} ];then
continue;
fi
list=$(find ${d1}${targetARM} | grep ".json")
for file in ${list}; do
sourcePath=$(echo "$file" | sed "s:target:src/main:g")
if test -f "$sourcePath"; then
echo "Replace ${sourcePath} with ${file}"
cp -f $file $sourcePath
fi
done
done
done
git status
git add --all
git commit -m "hard code pids"
git fetch --unshallow
git push ${authGitPath} ${tagbranch} -f
# remove existing tag
if [[ -n `git ls-remote --tags | grep "${tagname}"` ]]; then
git push ${authGitPath} --delete ${tagname} -f
fi
# create new tag
git tag ${tagname}
git push ${authGitPath} ${tagname} -f
git remote add upstream $gitToken@github.com:oracle/weblogic-azure.git
# ignore the error if cannot push, but log it
push_upstream_ignore_failure () { echo "push upstream result: $?" return 0; }
git push upstream ${tagname} -f || push_upstream_ignore_failure
git push ${authGitPath} --delete ${tagbranch} -f