forked from elementor/elementor
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (124 loc) · 4.58 KB
/
build.yml
File metadata and controls
144 lines (124 loc) · 4.58 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
135
136
137
138
139
140
141
142
143
144
name: Build
on:
pull_request:
branches:
- 'main'
- '3.[0-9][0-9]'
paths-ignore:
- '**.md'
- '**.txt'
- '.github/config.json'
- '.gitignore'
- 'docs/**'
workflow_dispatch:
workflow_call:
outputs:
artifact_name:
value: ${{ jobs.build-plugin.outputs.artifact_name }}
changelog_diff:
value: ${{ jobs.build-plugin.outputs.changelog_diff }}
push:
branches:
- 'main'
- '3.[0-9][0-9]'
paths-ignore:
- '**.md'
- '**.txt'
- '.github/config.json'
- 'bin/**'
- '.gitignore'
- 'docs/**'
permissions:
pull-requests: write
jobs:
build-plugin:
name: Build plugin
runs-on: ubuntu-22.04
if: startsWith( github.repository, 'elementor/' )
outputs:
artifact_name: ${{ env.PLUGIN_FOLDER_FILENAME}}
changelog_diff: ${{ steps.changelog_diff_files.outputs.diff }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Check if this is only a changelog PR
id: changelog_diff_files
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/*
.*/**/*
!readme.txt
!changelog.txt
- name: Install Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- name: Set ENV variables
run: |
DATE_VERSION=$(date '+%Y%m%d.%H%M')
VERSION=$(node -p "require('./package.json').version")
PACKAGE_VERSION=${VERSION}-${DATE_VERSION}
PLUGIN_FOLDER_FILENAME="elementor-${PACKAGE_VERSION}"
echo "DATE_VERSION=$DATE_VERSION" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "PLUGIN_FOLDER_FILENAME=$PLUGIN_FOLDER_FILENAME" >> $GITHUB_ENV
- name: Install dependencies
uses: ./.github/workflows/install-dependencies
- name: Build plugin
uses: ./.github/workflows/build-plugin
with:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
BUILD_SCRIPT_PATH: "./.github/scripts/build-zip.sh"
env:
MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }}
- uses: actions/upload-artifact@v4
id: upload-artifact
with:
name: ${{ env.PLUGIN_FOLDER_FILENAME }}
path: elementor
if-no-files-found: error
compression-level: 9
retention-days: 3
- name: Find existing comment on PR (Elementor repo)
if: github.event_name == 'pull_request' && startsWith( github.event.pull_request.head.repo.full_name, 'elementor/' )
uses: peter-evans/find-comment@v3
id: find
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Elementor Build'
- name: Comment build info on PR (Elementor repo)
if: github.event_name == 'pull_request' && startsWith( github.event.pull_request.head.repo.full_name, 'elementor/' )
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Elementor Build
Last updated at: ${{ env.DATE_VERSION }}
Version: ${{ env.PACKAGE_VERSION }}
✅ Elementor build is ready for download.
You can download the latest build from the link below:
🔗 [${{ env.PLUGIN_ZIP_FILENAME }}](https://github.com/elementor/elementor/actions/runs/${{ github.run_id }}/artifacts/${{ steps.upload-artifact.outputs.artifact-id }})
The build is available for 3 days.
edit-mode: replace
- name: Print artifact info once PR is non Elementor repo
if: github.event_name == 'pull_request' && !startsWith( github.event.pull_request.head.repo.full_name, 'elementor/' )
run: |
echo "Artifact info:"
echo " Name: ${{ env.PLUGIN_FOLDER_FILENAME }}"
echo " Path: elementor"
echo " Size: $(du -sh elementor | cut -f1)"
echo " URL: https://github.com/elementor/elementor/actions/runs/${{ env.RUN_ID }}/artifacts/${{ env.ARTIFACT_ID }}"
env:
RUN_ID: ${{ github.run_id }}
ARTIFACT_ID: ${{ steps.upload-artifact.outputs.artifact-id }}