-
Notifications
You must be signed in to change notification settings - Fork 3
196 lines (178 loc) · 7.7 KB
/
build_and_deploy.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Template configuration for Convertigo project CI build on GitHub Actions
# Please consult the GitHub documentation for details about settings
# https://docs.github.com/en/actions
#
# This sample assumes you have declared the following Encrypted Secrets
# https://docs.github.com/en/actions/reference/encrypted-secrets
#
# C8O_SERVER: Convertigo server endpoint, where the built mobile application will connect
# and the backend project will be deployed, like https://<myhost>/convertigo
# C8O_USER: Convertigo server admin or a user with role PROJECTS_CONFIG, used for the deploiment
# C8O_PASSWORD: Convertigo server password for the C8O_USER
#
# C8O_SERVER_PROD: override C8O_SERVER for tags
# C8O_USER_PROD: override C8O_USER for tags
# C8O_PASSWORD_PROD: override C8O_PASSWORD for tags
#
# Discover all tasks and -Pconvertigo options in your project build.gradle file.
name: No code studio CI
on:
push:
tags:
- '**'
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_KEY }}
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle Dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-caches-v1-${{ hashFiles('**/*.gradle', '**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-caches-v1-
- name: Cache Node Modules
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/_private/ionic/node_modules
${{ github.workspace }}/_private/ionic/.angular
/home/runner/convertigo/nodes
key: ${{ runner.os }}-build-node-${{ hashFiles('**/package.json', '**/_private/ionic/version.json') }}
restore-keys: ${{ runner.os }}-build-node-
- name: Convertigo generate application code
env:
C8O_SERVER: ${{secrets.testEndpoint}}
run: |
echo "Generate Mobile Builder App" && \
sh gradlew --stacktrace --info generateMobileBuilder export -x compileMobileBuilder \
-Pconvertigo.load.mobileApplicationEndpoint=$C8O_SERVER
- name: Build and deploy based on branch or tag
env:
C8O_SERVER: ${{secrets.testEndpoint}}
C8O_USER: ${{ secrets.testUserAdmin }}
C8O_PASSWORD: ${{ secrets.testUserPassword }}
run: |
echo "Deploying to test server $C8O_SERVER";
sh gradlew --stacktrace --info car deploy exportDependencies -x generateMobileBuilder \
-Pconvertigo.deploy.server=$C8O_SERVER \
-Pconvertigo.deploy.user=$C8O_USER \
-Pconvertigo.deploy.password=$C8O_PASSWORD
- name: Create "c8oforms_standalone" dockerized version
run: |
OLD_README=$(cat c8oforms_standalone/README.md)
curl -sL https://github.com/convertigo/docker/archive/refs/tags/c8oforms-2.1.0.tar.gz | tar xvz --strip-components=1 -C c8oforms_standalone
NEW_README=$(cat c8oforms_standalone/README.md)
echo -e "${OLD_README}\n\n${NEW_README}" > c8oforms_standalone/README.md
sed -i -e "s,HTTPD_ENABLE=0,HTTPD_ENABLE=1," -e "s,BASEROW_ENABLE=0,BASEROW_ENABLE=1," -e "s,HTTPD_ROOT_URL=/convertigo/,HTTPD_ROOT_URL=/convertigo/projects/C8Oforms/DisplayObjects/mobile/index.html," c8oforms_standalone/.env
mkdir -p c8oforms_standalone/data/workspace/projects/BaserowIntegration
find build -name "*.car" -exec unzip {} -d c8oforms_standalone/data/workspace/projects \;
curl -sL https://github.com/convertigo/c8oprj-baserowintegration/archive/refs/tags/c8oforms-2.1.0.tar.gz | tar xvz --strip-components=1 -C c8oforms_standalone/data/workspace/projects/BaserowIntegration
tar -czvf c8oforms_standalone.tar.gz c8oforms_standalone
- name: Save application project
uses: actions/upload-artifact@v4
with:
name: project
path: build/C8Oforms.car
- name: Save application c8oforms_standalone
uses: actions/upload-artifact@v4
with:
name: c8oforms_standalone.tar.gz
path: c8oforms_standalone.tar.gz
release:
needs: build_and_deploy
runs-on: ubuntu-latest
steps:
- name: Download CAR File
uses: actions/download-artifact@v4
with:
name: project
- name: Download c8oforms_standalone.tar.gz File
uses: actions/download-artifact@v4
with:
name: c8oforms_standalone.tar.gz
- name: Deploy to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
*.car
c8oforms_standalone.tar.gz
tag_name: ${{ github.ref_name }}
draft: ${{ contains( github.ref, 'beta' ) != true }}
prerelease: ${{ contains( github.ref, 'beta' )}}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
close_and_set_issues_to_be_tested:
needs: build_and_deploy
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-tags: true
ref: ${{ github.ref }}
- name: Get tag message
id: get_tag_message
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "Tag name: $TAG_NAME"
TAG_MESSAGE=$(git for-each-ref refs/tags/$TAG_NAME --format='%(contents)')
echo "Tag message: $TAG_MESSAGE"
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
echo "tag_message<<EOF" >> $GITHUB_OUTPUT
echo "$TAG_MESSAGE" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Extract issue numbers
id: extract_issues
run: |
TAG_MESSAGE="${{ steps.get_tag_message.outputs.tag_message }}"
echo "Tag message: $TAG_MESSAGE"
RAW_ISSUE_NUMBERS=$(echo "$TAG_MESSAGE" | grep -oE '#[0-9]+' || true)
ISSUE_NUMBERS=$(echo "$RAW_ISSUE_NUMBERS" | tr -d '#' | tr '\n' ' ')
echo "Found issue numbers: $ISSUE_NUMBERS"
echo "issue_numbers=$ISSUE_NUMBERS" >> $GITHUB_OUTPUT
shell: bash
- name: Post comment on issues
if: ${{ steps.extract_issues.outputs.issue_numbers != '' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tagName = "${{ steps.get_tag_message.outputs.tag_name }}";
const issueNumbers = "${{ steps.extract_issues.outputs.issue_numbers }}".split(' ');
const repoOwner = context.repo.owner;
const repoName = context.repo.repo;
const tagUrl = `https://github.com/${repoOwner}/${repoName}/tree/refs/tags/${tagName}`;
const commentBody = `To be tested in [${tagName}](${tagUrl})`;
for (const issueNumber of issueNumbers) {
if (issueNumber) {
console.log(`Posting comment to issue #${issueNumber}`);
await github.rest.issues.createComment({
owner: repoOwner,
repo: repoName,
issue_number: parseInt(issueNumber),
body: commentBody
});
console.log(`Closing issue #${issueNumber}`);
await github.rest.issues.update({
owner: repoOwner,
repo: repoName,
issue_number: parseInt(issueNumber),
state: 'closed'
});
}
}