Skip to content

Commit 74e348a

Browse files
authored
Internal: Create deploy workflow [TMZ-803] (#578)
1 parent e4fe5a4 commit 74e348a

File tree

5 files changed

+109
-655
lines changed

5 files changed

+109
-655
lines changed
Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
11
#!/bin/bash
22
set -eo pipefail
33

4-
echo "🧪 DRY RUN MODE: Will simulate SVN operations without committing"
4+
echo "DRY RUN MODE: Will simulate SVN operations without committing"
55

66
if [[ -z "$THEME_VERSION" ]]; then
77
echo "Set the THEME_VERSION env var"
88
exit 1
99
fi
1010

11-
if [[ -z "$THEME_SLUG" ]]; then
12-
echo "Set the THEME_SLUG env var"
13-
exit 1
14-
fi
15-
16-
if [[ -z "$BUILD_DIR" ]]; then
17-
echo "Set the BUILD_DIR env var"
18-
exit 1
19-
fi
20-
2111
# Ensure SVN is installed
2212
svn --version
2313

2414
echo "SVN installed"
2515

2616
echo "Publish theme version: ${THEME_VERSION}"
27-
echo "Theme slug: ${THEME_SLUG}"
28-
echo "Build directory: ${BUILD_DIR}"
2917

3018
THEME_PATH="$GITHUB_WORKSPACE"
3119
SVN_PATH="$GITHUB_WORKSPACE/svn"
@@ -36,42 +24,42 @@ pwd
3624
mkdir -p $SVN_PATH
3725
cd $SVN_PATH
3826

39-
echo "🧪 DRY RUN: Checking out SVN repository (read-only)"
40-
svn co --depth immediates "https://themes.svn.wordpress.org/${THEME_SLUG}" . 2>&1 | head -20 || {
41-
echo "⚠️ Could not checkout repository (may require auth for some operations)"
42-
echo " This is normal - simulating checkout for dry-run"
27+
echo "DRY RUN: Checking out SVN repository (read-only)"
28+
svn co --depth immediates "https://themes.svn.wordpress.org/hello-elementor" . 2>&1 | head -20 || {
29+
echo "Could not checkout repository (may require auth for some operations)"
30+
echo "This is normal - simulating checkout for dry-run"
4331
mkdir -p "$VERSION_DIR"
4432
cd "$VERSION_DIR"
4533
}
4634

4735
echo "Check if version folder already exists"
4836
VERSION_EXISTS=false
49-
if svn list "https://themes.svn.wordpress.org/${THEME_SLUG}/${VERSION_DIR}" > /dev/null 2>&1; then
37+
if svn list "https://themes.svn.wordpress.org/hello-elementor/${VERSION_DIR}" > /dev/null 2>&1; then
5038
VERSION_EXISTS=true
5139
fi
5240

5341
if [[ "$VERSION_EXISTS" == "true" ]]; then
54-
echo "ERROR: Version folder $VERSION_DIR already exists in SVN!
55-
SVN URL: https://themes.svn.wordpress.org/${THEME_SLUG}/${VERSION_DIR}
42+
echo "ERROR: Version folder $VERSION_DIR already exists in SVN!
43+
SVN URL: https://themes.svn.wordpress.org/hello-elementor/${VERSION_DIR}
5644
5745
WordPress.org theme versions are immutable - you cannot update an existing version.
5846
If you need to make changes, create a new version (e.g., increment patch/minor/major).
5947
60-
🧪 DRY RUN: Would fail here (version already exists)"
48+
DRY RUN: Would fail here (version already exists)"
6149
exit 0
6250
fi
6351

6452
mkdir -p "$VERSION_DIR"
6553
cd "$VERSION_DIR"
6654

6755
echo "Copy files from build directory"
68-
rsync -ah --progress "$THEME_PATH/$BUILD_DIR/"* . || rsync -ah --progress "$THEME_PATH/$BUILD_DIR/." . || true
56+
rsync -ah --progress "$THEME_PATH/hello-elementor/"* . || rsync -ah --progress "$THEME_PATH/hello-elementor/." . || true
6957

7058
echo "Preparing files for SVN"
7159
svn status 2>/dev/null || echo ""
7260

7361
echo "svn add new files"
74-
echo "🧪 DRY RUN: Would add new files"
62+
echo "DRY RUN: Would add new files"
7563
svn status 2>/dev/null | grep -v '^.[ \t]*\\..*' | { grep '^?' || true; } | awk '{print $2}' | sed 's|^| Would add: |' || true
7664

7765
echo ""
@@ -87,36 +75,36 @@ if [ -n "$SVN_STATUS" ]; then
8775
MODIFIED_COUNT=$(echo "$SVN_STATUS" | grep -c "^M" || echo "0")
8876
UNTRACKED_COUNT=$(echo "$SVN_STATUS" | grep -c "^?" || echo "0")
8977

90-
echo " Added (A): $ADDED_COUNT files"
78+
echo "Added (A): $ADDED_COUNT files"
9179
if [ "$MODIFIED_COUNT" -gt 0 ]; then
92-
echo " Modified (M): $MODIFIED_COUNT files"
80+
echo "Modified (M): $MODIFIED_COUNT files"
9381
fi
9482
if [ "$UNTRACKED_COUNT" -gt 0 ]; then
95-
echo " ⚠️ Untracked (?): $UNTRACKED_COUNT files (would be added)"
83+
echo "Untracked (?): $UNTRACKED_COUNT files (would be added)"
9684
fi
9785
echo ""
9886
TOTAL_CHANGES=$((ADDED_COUNT + MODIFIED_COUNT))
99-
echo " Total files that would be committed: $TOTAL_CHANGES files"
87+
echo "Total files that would be committed: $TOTAL_CHANGES files"
10088
else
101-
echo " (No changes detected - files are up to date)"
89+
echo "(No changes detected - files are up to date)"
10290
fi
10391
echo "=========================================="
10492
echo ""
10593

10694
if [ "$TOTAL_CHANGES" -gt 0 ]; then
107-
echo "🧪 DRY RUN: Would commit $TOTAL_CHANGES files to version folder $VERSION_DIR"
108-
echo " Commit message: Upload v${THEME_VERSION}"
95+
echo "DRY RUN: Would commit $TOTAL_CHANGES files to version folder $VERSION_DIR"
96+
echo "Commit message: Upload v${THEME_VERSION}"
10997
else
110-
echo "🧪 DRY RUN: No changes to commit (files are up to date)"
98+
echo "DRY RUN: No changes to commit (files are up to date)"
11199
fi
112-
echo " 🚫 No actual commit performed (dry-run mode)"
100+
echo "No actual commit performed (dry-run mode)"
113101

114102
echo "Remove the SVN folder from the workspace"
115103
rm -rf $SVN_PATH
116104

117105
echo "Back to the workspace root"
118106
cd $GITHUB_WORKSPACE
119107

120-
echo "Dry-run complete: v${THEME_VERSION}"
121-
echo " All checks passed - ready for actual deployment"
108+
echo "Dry-run complete: v${THEME_VERSION}"
109+
echo "All checks passed - ready for actual deployment"
122110

.github/scripts/publish-theme-to-wordpress-org.sh

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ if [[ -z "$THEME_VERSION" ]]; then
1616
exit 1
1717
fi
1818

19-
if [[ -z "$THEME_SLUG" ]]; then
20-
echo "Set the THEME_SLUG env var"
21-
exit 1
22-
fi
23-
24-
if [[ -z "$BUILD_DIR" ]]; then
25-
echo "Set the BUILD_DIR env var"
26-
exit 1
27-
fi
28-
2919
# Ensure SVN is installed
3020
svn --version
3121

@@ -43,12 +33,12 @@ mkdir -p $SVN_PATH
4333
cd $SVN_PATH
4434

4535
echo "Checkout from SVN"
46-
svn co --depth immediates "https://themes.svn.wordpress.org/${THEME_SLUG}" .
36+
svn co --depth immediates "https://themes.svn.wordpress.org/hello-elementor" .
4737

4838
echo "Check if version folder already exists"
49-
if svn list "https://themes.svn.wordpress.org/${THEME_SLUG}/${VERSION_DIR}" > /dev/null 2>&1; then
50-
echo "ERROR: Version folder $VERSION_DIR already exists in SVN!
51-
SVN URL: https://themes.svn.wordpress.org/${THEME_SLUG}/${VERSION_DIR}
39+
if svn list "https://themes.svn.wordpress.org/hello-elementor/${VERSION_DIR}" > /dev/null 2>&1; then
40+
echo "ERROR: Version folder $VERSION_DIR already exists in SVN!
41+
SVN URL: https://themes.svn.wordpress.org/hello-elementor/${VERSION_DIR}
5242
5343
WordPress.org theme versions are immutable - you cannot update an existing version.
5444
If you need to make changes, create a new version (e.g., increment patch/minor/major)."
@@ -62,7 +52,7 @@ svn add "$VERSION_DIR"
6252
cd "$VERSION_DIR"
6353

6454
echo "Copy files"
65-
rsync -ah --progress "$THEME_PATH/$BUILD_DIR/"* . || rsync -ah --progress "$THEME_PATH/$BUILD_DIR/." . || true
55+
rsync -ah --progress "$THEME_PATH/hello-elementor/"* . || rsync -ah --progress "$THEME_PATH/hello-elementor/." . || true
6656

6757
echo "Preparing files"
6858
cd "$VERSION_DIR"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
if [[ -z "$VERSION" ]]; then
5+
echo "Set the VERSION env var"
6+
exit 1
7+
fi
8+
9+
if [[ ! -f "readme.txt" ]]; then
10+
echo "readme.txt file does not exist"
11+
exit 1
12+
fi
13+
14+
if ! grep -q "= ${VERSION} -" readme.txt; then
15+
echo "readme.txt file does not contain changelog entry for version: ${VERSION}"
16+
echo "Expected format: = ${VERSION} - DATE"
17+
exit 1
18+
fi
19+

.github/workflows/deploy.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Deploy
2+
3+
permissions:
4+
contents: read
5+
actions: read
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
dry_run:
11+
type: boolean
12+
description: 'Dry run mode (test without deploying)'
13+
required: false
14+
default: false
15+
16+
jobs:
17+
build:
18+
if: ( github.actor == 'ManorHazaz' || github.actor == 'hein-obox' || github.actor == 'KingYes' || github.actor == 'arielk' || github.actor == 'nicoladj77' ) && startsWith( github.repository, 'elementor/' )
19+
uses: ./.github/workflows/build.yml
20+
secrets: inherit
21+
22+
deploy:
23+
needs: build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
- name: Preparing envs
29+
run: |
30+
echo "THEME_VERSION=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV
31+
- name: Download Artifact
32+
uses: actions/download-artifact@v4
33+
with:
34+
name: hello-elementor
35+
- name: Validate changelog
36+
env:
37+
VERSION: ${{ env.THEME_VERSION }}
38+
run: |
39+
bash "${GITHUB_WORKSPACE}/.github/scripts/validate-changelog.sh"
40+
- name: Install SVN
41+
run: |
42+
sudo apt-get update -y
43+
sudo apt-get install -y subversion
44+
which svn
45+
svn --version
46+
- name: Publish to WordPress.org SVN (Dry Run)
47+
if: ${{ inputs.dry_run == true }}
48+
run: |
49+
bash "${GITHUB_WORKSPACE}/.github/scripts/publish-theme-to-wordpress-org-dry-run.sh"
50+
- name: Publish to WordPress.org SVN
51+
if: ${{ inputs.dry_run == false }}
52+
env:
53+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
54+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
55+
run: |
56+
bash "${GITHUB_WORKSPACE}/.github/scripts/publish-theme-to-wordpress-org.sh"
57+
- name: Send Slack Notification
58+
if: ${{ inputs.dry_run == false }}
59+
uses: ./.github/actions/theme-slack-notification-release
60+
with:
61+
CLOUD_SLACK_BOT_TOKEN: ${{ secrets.CLOUD_SLACK_BOT_TOKEN }}
62+
PACKAGE_VERSION: ${{ env.THEME_VERSION }}
63+
SLACK_CHANNEL: "#tmz-hello-delivery"

0 commit comments

Comments
 (0)