-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (117 loc) · 4.71 KB
/
build.yml
File metadata and controls
134 lines (117 loc) · 4.71 KB
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
name: Build and Publish
on:
push:
branches:
- master
- develop
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout module repository
uses: actions/checkout@v4
with:
fetch-depth: 0
path: module
- name: Checkout workflows repository
uses: actions/checkout@v4
with:
repository: mikopbx/.github-workflows
path: .github-workflows
- name: Validate module configuration
id: validate
uses: ./.github-workflows/.github/actions/validate
- name: Manage versions
id: version
uses: ./.github-workflows/.github/actions/versioning
with:
initial_version: "1.84"
- name: Setup build environment
uses: ./.github-workflows/.github/actions/docker-build
with:
php_version: ${{ steps.validate.outputs.php_version }}
- name: Handle dependencies
uses: ./.github-workflows/.github/actions/composer
with:
php_version: ${{ steps.validate.outputs.php_version }}
- name: Cache Docker images
uses: actions/cache@v3
id: docker-cache
with:
path: ${{ runner.temp }}/docker-cache-*.tar
key: ${{ runner.os }}-docker-${{ hashFiles('module/**/Dockerfile') }}
restore-keys: |
${{ runner.os }}-docker-
- name: Replace OAuth placeholders
env:
AMO_CLIENT_ID: ${{ secrets.AMO_CLIENT_ID }}
AMO_CLIENT_SECRET: ${{ secrets.AMO_CLIENT_SECRET }}
AMO_REDIRECT_URL: ${{ secrets.AMO_REDIRECT_URL }}
run: |
cd module
sed -i "s|%CLIENT_ID%|$AMO_CLIENT_ID|g" Lib/AmoCrmMainBase.php
sed -i "s|%CLIENT_SECRET%|$AMO_CLIENT_SECRET|g" Lib/AmoCrmMainBase.php
sed -i "s|%REDIRECT_URL%|$AMO_REDIRECT_URL|g" Lib/AmoCrmMainBase.php
echo "AmoCrmMainBase.php placeholders replaced."
- name: Build widget
run: |
cd module
WIDGET_VERSION="1.0.$(git rev-list --count HEAD)"
sed -i "s|%WidgetVersion%|$WIDGET_VERSION|g" widget/manifest.json
sed -i "s|%WidgetVersion%|$WIDGET_VERSION|g" widget/script.js
cd widget && zip -r "$RUNNER_TEMP/widget.zip" . -x "*.DS_Store*" && cd ..
echo "Widget built: widget.zip (version $WIDGET_VERSION)"
rm -rf widget
echo "widget/ removed from module archive."
- name: Sync translations from Core
uses: ./.github-workflows/.github/actions/sync-translations
- name: Create module package
id: archive
uses: ./.github-workflows/.github/actions/archive
with:
version: ${{ steps.version.outputs.new_version }}
- name: Generate changelog
id: changelog
if: steps.validate.outputs.changelog_enabled == 'true'
uses: ./.github-workflows/.github/actions/changelog
- name: Publish module
if: |
github.ref == 'refs/heads/master' &&
steps.validate.outputs.publish_release == 'true'
env:
OWNCLOUD_AUTH: ${{ secrets.OWNCLOUD_AUTH }}
WEBDAV_ROOT: ${{ secrets.WEBDAV_ROOT }}
SHARE_API_URL: ${{ secrets.SHARE_API_URL }}
MIKO_LIC_REST_VENDOR_ID: ${{ secrets.MIKO_LIC_REST_VENDOR_ID }}
MIKO_LIC_REST_API_KEY: ${{ secrets.MIKO_LIC_REST_API_KEY }}
MIKO_LIC_HOSTNAME: ${{ secrets.MIKO_LIC_HOSTNAME }}
uses: ./.github-workflows/.github/actions/publish
with:
php_version: ${{ steps.validate.outputs.php_version }}
module_filename: ${{ steps.archive.outputs.filename }}
version: ${{ steps.version.outputs.new_version }}
changelog: ${{ steps.changelog.outputs.changelog }}
- name: Manage GitHub releases
if: steps.validate.outputs.create_github_release == 'true'
uses: ./.github-workflows/.github/actions/release
with:
version: ${{ steps.version.outputs.new_version }}
version_tag: ${{ steps.version.outputs.new_version_tag }}
module_filename: ${{ steps.archive.outputs.filename }}
changelog: ${{ steps.changelog.outputs.changelog }}
- name: Upload widget to release
if: steps.validate.outputs.create_github_release == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.version.outputs.new_version_tag }}"
if [ -n "$TAG" ] && gh release view "$TAG" &>/dev/null; then
gh release upload "$TAG" "$RUNNER_TEMP/widget.zip" --clobber
echo "widget.zip uploaded to release $TAG"
else
echo "Release $TAG not found, skipping widget upload."
fi