-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (118 loc) · 4.71 KB
/
build-release.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
---
name: Build Release
on:
pull_request:
types: [closed]
branches: [main.8.x]
workflow_dispatch:
inputs:
BASELINE:
description: 'Release branch'
required: true
default: 'main.8.x'
env:
NPM_REGISTRY: https://registry.npmjs.org/
CI_EMAIL: ontimize-web@imatia.com
CI_USERNAME: ontimize-web
DEVELOP_BRANCH: 8.x.x
jobs:
build:
runs-on: ubuntu-20.04
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release'))
steps:
- name: Get input parameters
run: |
echo "BASELINE_BRANCH=${{ github.event.inputs.BASELINE || github.ref }}" >> $GITHUB_ENV
- name: Checkout merge commit
uses: actions/checkout@v3
with:
ref: ${{ env.BASELINE_BRANCH }}
fetch-depth: 0
- name: 'Cache node modules'
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node 12.x
uses: actions/setup-node@v3
with:
node-version: 12.13.0
registry-url: ${{ env.NPM_REGISTRY }}
- name: obtain package.json version
id: project
run: |
echo "version=$(node -pe "require('./package.json')['version']")" >> $GITHUB_OUTPUT
- name: abort if SNAPSHOT
if: "contains(steps.project.outputs.version, 'SNAPSHOT')"
run: |
echo "Version ${{ steps.project.outputs.version }} is not a properly named for RELEASE"
exit 1
- name: npm install and npm run build
run: |
npm i
npm run production-aot-server
mkdir -p dist/ftp && tar -cvf dist/ftp/dist.tar dist/*
- name: backup previous deploy
uses: garygrossgarten/github-action-ssh@release
with:
command: cd /home/systems/ftp-demos && ls -l -a && ./backup-project playground8
host: ${{ secrets.OWEB_CLOUD_DEMOS_HOST }}
port: ${{ secrets.OWEB_CLOUD_DEMOS_PORT }}
username: ${{ secrets.OWEB_CLOUD_DEMOS_USERNAME }}
password: ${{ secrets.OWEB_CLOUD_DEMOS_PASSWORD }}
env:
CI: true
- name: 📂 Sync files
uses: wangyucode/sftp-upload-action@v2.0.2
with:
host: ${{ secrets.OWEB_CLOUD_DEMOS_HOST }}
port: ${{ secrets.OWEB_CLOUD_DEMOS_PORT }}
username: ${{ secrets.OWEB_CLOUD_DEMOS_USERNAME }}
password: ${{ secrets.OWEB_CLOUD_DEMOS_PASSWORD }}
localDir: dist/ftp/
remoteDir: /home/systems/ftp-demos/playground8/
- name: deploy pm2
uses: garygrossgarten/github-action-ssh@release
with:
command: cd /home/systems/ftp-demos && ls -l -a && echo ${{ secrets.OWEB_CLOUD_DEMOS_PASSWORD }} | sudo -S ./deploy-project playground8
host: ${{ secrets.OWEB_CLOUD_DEMOS_HOST }}
port: ${{ secrets.OWEB_CLOUD_DEMOS_PORT }}
username: ${{ secrets.OWEB_CLOUD_DEMOS_USERNAME }}
password: ${{ secrets.OWEB_CLOUD_DEMOS_PASSWORD }}
env:
CI: true
- name: GitHub Release / Create release
uses: ncipollo/release-action@2792aea87063cfd0d27953ac38e3ab45afacc154
with:
commit: ${{ env.BASELINE_BRANCH }}
tag: ${{ steps.project.outputs.version }}
name: ${{ steps.project.outputs.version }}
token: ${{ secrets.OWEB_GH_TOKEN_PUSH }}
body: |
Released version ${{ steps.project.outputs.version }} of Playground
- name: Prepare git information
run: |
git config user.name "$CI_USERNAME"
git config user.email "$CI_EMAIL"
- name: bumping version in package.json
run: |
npm version $(npm version minor --no-git-tag-version)-SNAPSHOT-0 --no-git-tag-version
- name: Create sync branch
run: |
version=${{ steps.project.outputs.version }}
git checkout -b sync/release-$version-to-develop
git add .
git commit --allow-empty -m "Prepare next development iteration"
git push origin sync/release-$version-to-develop
- name: Create pull request
env:
GITHUB_TOKEN: ${{ secrets.OWEB_GH_TOKEN_PUSH }}
run: |
version=${{ steps.project.outputs.version }}
MESSAGE="
Automated pull request for synchronizing released version ($version) into develop branch
### 💡 Merge Strategy: Create a merge commit
"
gh pr create -B ${{ env.DEVELOP_BRANCH }} -H sync/release-$version-to-develop --title "Sync release $version to develop" --body "$(echo -e "$MESSAGE")"