@@ -5,11 +5,18 @@ name: Auto-testing-builds & Deployments
5
5
on :
6
6
push :
7
7
8
+ env :
9
+ builds-directory : ~/builds/athemes
10
+
8
11
# Defines the jobs that will be executed as part of this workflow.
9
12
jobs :
10
- build :
11
- # Specifies the runner environment for the job. In this case, it\'s Ubuntu 22.04.
12
- runs-on : ubuntu-22.04
13
+ create-testing-build :
14
+ uses : awesomemotive/Botiga/.github/workflows/build.yml@main
15
+
16
+ upload-testing-build :
17
+ name : Prepare and upload builds in hub.wpforms.com/builds
18
+ runs-on : self-hosted
19
+ needs : create-testing-build
13
20
if : " !contains(github.event.head_commit.message, 'ci skip')"
14
21
15
22
# Defines the sequence of steps that make up the \'build\' job.
@@ -18,114 +25,22 @@ jobs:
18
25
- name : GitHub Environment Variables Action
19
26
uses :
FranzDiebold/[email protected]
20
27
21
- # Sets a project name based on the GitHub repository name.
22
- # It extracts the repository name, converts it to lowercase, and saves it as an environment variable PROJECT_NAME.
23
28
- name : Set Project Name
24
29
run : |
25
30
repo_full_name="${{ github.repository }}"
26
31
repo_short_name="${repo_full_name##*/}"
27
32
echo "PROJECT_NAME=${repo_short_name,,}" >> $GITHUB_ENV
28
33
29
- # Checks out the repository\'s code so the workflow can access it.
30
- - name : Checkout code
31
- uses : actions/checkout@v5
32
-
33
- # Sets up PHP version 8.0 and installs Composer.
34
- - name : Setup PHP 8.0
35
- uses : shivammathur/setup-php@v2
36
- with :
37
- php-version : 8.0
38
- tools : composer
39
-
40
- # Installs Node.js version 21.
41
- - name : Install Node.js
42
- uses : actions/setup-node@v2
43
- with :
44
- node-version : 21
45
-
46
- # Installs PHP dependencies for a production environment using Composer.
47
- # --no-dev: Skips development dependencies.
48
- # --ignore-platform-reqs: Ignores PHP version and extension requirements.
49
- # --prefer-dist: Downloads and unpacks archives instead of cloning from version control.
50
- # --no-scripts: Prevents execution of scripts defined in composer.json.
51
- # --optimize-autoloader: Converts PSR-0/4 rules into classmap rules for faster class loading.
52
- - name : Install dependencies
53
- run : composer install --no-dev --ignore-platform-reqs --prefer-dist --no-scripts --optimize-autoloader
54
-
55
- # Installs Node.js dependencies using npm.
56
- - name : Install nodejs dependencies
57
- run : npm install
58
-
59
- # Compiles and bundles assets for production.
60
- - name : Generate production build
61
- run : npm run production
62
-
63
- # Generates translation files for the project.
64
- - name : Generate translation files
65
- run : npm run translate
66
-
67
- # Removes unnecessary files and directories to create a clean build for deployment.
68
- # This includes development-related files, version control directories, and source assets.
69
- - name : Clean unneeded files
70
- run : |
71
- [ -d .github ] && rm -r .github
72
- [ -d .git ] && rm -r .git
73
- [ -d assets/sass ] && rm -r assets/sass
74
- [ -d assets/js/src ] && rm -r assets/js/src
75
- [ -d node_modules ] && rm -r node_modules
76
- [ -d tests ] && rm -r tests
77
- [ -d .cursor ] && rm -r .cursor
78
- [ -f .gitattributes ] && rm .gitattributes
79
- [ -f .gitignore ] && rm .gitignore
80
- [ -f phpcs.xml ] && rm phpcs.xml
81
- [ -f wpgulp.config.js ] && rm wpgulp.config.js
82
- [ -f gulpfile.babel.js ] && rm gulpfile.babel.js
83
- [ -f composer.json ] && rm composer.json
84
- [ -f composer.lock ] && rm composer.lock
85
- [ -f package.json ] && rm package.json
86
- [ -f readme.md ] && rm readme.md
87
- [ -f package-lock.json ] && rm package-lock.json
88
-
89
- # Creates a new directory named after the project to hold the build files.
90
- - name : Create directory for the build
91
- run : mkdir ${{ env.PROJECT_NAME }}
92
-
93
- # Moves all the cleaned project files into the newly created build directory.
94
- - name : Move files to the build directory
95
- run : rsync -av --progress --exclude=${{ env.PROJECT_NAME }} . ${{ env.PROJECT_NAME }}/
96
-
97
- # Creates a zip archive of the build directory.
98
- - name : Create Artifact
99
- run : zip -qq -r "${{ env.PROJECT_NAME }}.zip" ${{ env.PROJECT_NAME }}/
100
-
101
- # The following steps are for uploading the build to hub.wpforms.com.
102
- # Sets up an SSH key to securely connect to the deployment server.
103
- # The private key is stored as a secret.
104
- - name : Setup SSH key for hub.wpforms.com upload
105
- run : |
106
- mkdir -p ~/.ssh
107
- echo "${{ secrets.WPFORMS_TEST_DOCKER_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
108
- chmod 600 ~/.ssh/id_ed25519
109
- chmod 700 ~/.ssh
110
-
111
- # Creates the necessary directory structure on the local runner before uploading.
112
- - name : Create builds directory structure
113
- run : |
114
- mkdir -p builds/${{ env.PROJECT_NAME }}/${{ env.CI_REF_NAME_SLUG }}
115
- cp ${{ env.PROJECT_NAME }}.zip builds/${{ env.PROJECT_NAME }}/${{ env.CI_REF_NAME_SLUG }}/
116
-
117
- # Uploads the build to the deployment server using rsync over SSH.
34
+ # Uploads the build to the server using rsync over SSH.
118
35
# --rsh: Specifies the remote shell to use (ssh with specific options).
119
36
# -o StrictHostKeyChecking=no: Disables host key checking.
120
- # -p18765: Specifies the port for the SSH connection.
121
37
# --ignore-times: Doesn\'t skip files that have the same size and modification time.
122
38
# --archive: Archive mode, equivalent to -rlptgoD.
123
39
# --verbose: Increases verbosity.
124
40
# --compress: Compresses file data during the transfer.
125
41
# --human-readable: Outputs numbers in a human-readable format.
126
42
# --progress: Shows progress during transfer.
127
43
# --whole-file: Copies files whole (without delta-xfer algorithm).
128
- # --remove-source-files: Removes files from the source directory after they are transferred.
129
44
- name : Upload to hub.wpforms.com
130
45
run : |
131
46
rsync --rsh="ssh -o StrictHostKeyChecking=no -p18765" \
@@ -136,14 +51,5 @@ jobs:
136
51
--human-readable \
137
52
--progress \
138
53
--whole-file \
139
- --remove-source-files \
140
- builds/ \
141
- [email protected] :/home/staging/shared/hub.wpforms.com/builds/athemes/
142
-
143
- # Uploads the generated zip file as a workflow artifact.
144
- # This allows the build to be downloaded from the GitHub Actions run page.
145
- - name : Upload file list as artifact
146
- uses : actions/upload-artifact@v4
147
- with :
148
- name : ${{ env.PROJECT_NAME }}.zip
149
- path : ${{ env.PROJECT_NAME }}.zip
54
+ ${{ env.builds-directory }}/${{ env.PROJECT_NAME }}/${{ env.CI_REF_NAME_SLUG }}/${{ env.PROJECT_NAME }}.zip \
55
+ [email protected] :/home/staging/shared/hub.wpforms.com/builds/athemes/${{ env.PROJECT_NAME }}/${{ env.CI_REF_NAME_SLUG }}/
0 commit comments