Skip to content

Commit f58fb78

Browse files
committed
Update gh actions
1 parent 6056965 commit f58fb78

File tree

4 files changed

+43
-15
lines changed

4 files changed

+43
-15
lines changed

.github/workflows/auto-testing-builds.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
build:
1111
# Specifies the runner environment for the job. In this case, it\'s Ubuntu 22.04.
1212
runs-on: ubuntu-22.04
13+
if: "!contains(github.event.head_commit.message, 'ci skip')"
1314

1415
# Defines the sequence of steps that make up the \'build\' job.
1516
steps:
@@ -27,7 +28,7 @@ jobs:
2728
2829
# Checks out the repository\'s code so the workflow can access it.
2930
- name: Checkout code
30-
uses: actions/checkout@v2
31+
uses: actions/checkout@v5
3132

3233
# Sets up PHP version 8.0 and installs Composer.
3334
- name: Setup PHP 8.0
@@ -67,23 +68,22 @@ jobs:
6768
# This includes development-related files, version control directories, and source assets.
6869
- name: Clean unneeded files
6970
run: |
70-
[ -f .gitattributes ] && rm .gitattributes
7171
[ -d .github ] && rm -r .github
7272
[ -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+
[ -f .gitattributes ] && rm .gitattributes
7378
[ -f .gitignore ] && rm .gitignore
7479
[ -f phpcs.xml ] && rm phpcs.xml
7580
[ -f wpgulp.config.js ] && rm wpgulp.config.js
7681
[ -f gulpfile.babel.js ] && rm gulpfile.babel.js
7782
[ -f composer.json ] && rm composer.json
7883
[ -f composer.lock ] && rm composer.lock
7984
[ -f package.json ] && rm package.json
80-
[ -f package-lock.json ] && rm package-lock.json
8185
[ -f readme.md ] && rm readme.md
82-
[ -f playwright.config.js ] && rm playwright.config.js
83-
[ -d assets/sass ] && rm -r assets/sass
84-
[ -d assets/js/src ] && rm -r assets/js/src
85-
[ -d node_modules ] && rm -r node_modules
86-
[ -d e2etests ] && rm -r e2etests
86+
[ -f package-lock.json ] && rm package-lock.json
8787
8888
# Creates a new directory named after the project to hold the build files.
8989
- name: Create directory for the build

.github/workflows/auto_builds_cleanup.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ name: Auto-builds PR Cleanup
55
on:
66
pull_request:
77
types: [ closed ]
8+
branches-ignore: [ main ]
89

910
jobs:
10-
build:
11+
cleaning:
1112
# The type of runner that the job will run on.
1213
runs-on: ubuntu-22.04
1314

@@ -16,6 +17,13 @@ jobs:
1617
- name: GitHub Environment Variables Action
1718
uses: FranzDiebold/[email protected]
1819

20+
# This step installs the SSH key to allow the runner to authenticate with the staging server.
21+
- name: Install SSH Key
22+
uses: shimataro/ssh-key-action@v2
23+
with:
24+
key: ${{ secrets.WPFORMS_TEST_DOCKER_SSH_PRIVATE_KEY }}
25+
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
26+
1927
# This step sets a project name environment variable based on the repository name.
2028
# It takes the full repository name (e.g., "owner/repo"), extracts the repository name part,
2129
# converts it to lowercase, and saves it as PROJECT_NAME in the GitHub environment.
@@ -34,7 +42,10 @@ jobs:
3442
chmod 600 ~/.ssh/id_ed25519
3543
chmod 700 ~/.ssh
3644
45+
- name: Adding Known Hosts
46+
run: ssh-keyscan -p 18765 -H ${{ secrets.WPFORMS_STAGING_HOST }} >> ~/.ssh/known_hosts
47+
3748
# This step connects to the staging server via SSH and deletes the build directory
3849
# associated with the closed pull request's branch.
3950
- name: Delete builds from merged branch
40-
run: ssh -p18765 staging@34.68.130.55 "cd /home/staging/shared/hub.wpforms.com/builds/athemes/${{ env.PROJECT_NAME }} && rm -rf ${{ env.CI_REF_NAME_SLUG }}"
51+
run: ssh -p18765 staging@${{ secrets.WPFORMS_STAGING_HOST }} "cd /home/staging/shared/hub.wpforms.com/builds/athemes/${{ env.PROJECT_NAME }} && rm -rf ${{ env.CI_ACTION_REF_NAME_SLUG }}"

.github/workflows/auto_builds_cleanup_daily.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,27 @@ name: Auto-builds Daily Cleanup
1111
- cron: '1 0 * * *' # Runs the workflow every day at 00:01.
1212

1313
jobs:
14-
builds:
14+
cleaning:
1515
name: Delete builds for non existing branches
1616
runs-on: ubuntu-22.04
1717

1818
steps:
19+
20+
# This step checks out the code to allow the workflow to access it.
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
1924
# This action exposes GitHub environment variables to be used in subsequent steps.
2025
- name: GitHub Environment Variables Action
2126
uses: FranzDiebold/[email protected]
2227

28+
# This step installs the SSH key to allow the runner to authenticate with the staging server.
29+
- name: Install SSH Key
30+
uses: shimataro/ssh-key-action@v2
31+
with:
32+
key: ${{ secrets.WPFORMS_TEST_DOCKER_SSH_PRIVATE_KEY }}
33+
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
34+
2335
# This step extracts the repository name from the full repository path and sets it as a PROJECT_NAME environment variable.
2436
# e.g. if the repository is aThemes/merchant, the project name will be "merchant".
2537
- name: Set Project Name
@@ -37,6 +49,10 @@ jobs:
3749
chmod 600 ~/.ssh/id_ed25519
3850
chmod 700 ~/.ssh
3951
52+
# This step adds the known hosts to the SSH key.
53+
- name: Adding Known Hosts
54+
run: ssh-keyscan -p 18765 -H ${{ secrets.WPFORMS_STAGING_HOST }} >> ~/.ssh/known_hosts
55+
4056
# This step fetches the latest list of remote branches, formats the branch names, and saves them to a file named branches.txt.
4157
# The formatting removes the "origin/" prefix and replaces slashes and dots with hyphens.
4258
- name: Prepare list of branches
@@ -50,7 +66,7 @@ jobs:
5066
# This step connects to the staging server via SSH and lists the contents of the auto-builds directory for the current project.
5167
# The list of auto-builds is saved to a file named auto-builds.txt.
5268
- name: Get list of auto-builds
53-
run: ssh -p18765 staging@34.68.130.55 "cd /home/staging/shared/hub.wpforms.com/builds/athemes/${{ env.PROJECT_NAME }} && ls" > auto-builds.txt
69+
run: ssh -p18765 staging@${{ secrets.WPFORMS_STAGING_HOST }} "cd /home/staging/shared/hub.wpforms.com/builds/athemes/${{ env.PROJECT_NAME }} && ls" > auto-builds.txt
5470

5571
# This step reads the auto-builds.txt file line by line.
5672
# For each auto-build, it checks if a corresponding branch exists in the branches.txt file.
@@ -66,6 +82,6 @@ jobs:
6682
if ! grep -q "$dir" branches.txt
6783
then
6884
echo "Deleting auto-build: $dir"
69-
ssh -n -p18765 staging@34.68.130.55 "cd /home/staging/shared/hub.wpforms.com/builds/athemes/${{ env.PROJECT_NAME }} && rm -rf $dir"
85+
ssh -n -p18765 staging@${{ secrets.WPFORMS_STAGING_HOST }} "cd /home/staging/shared/hub.wpforms.com/builds/athemes/${{ env.PROJECT_NAME }} && rm -rf $dir"
7086
fi
7187
done < auto-builds.txt

.github/workflows/production-theme.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ jobs:
4141
- name: Clean unneeded files
4242
run: |
4343
[ -f .gitattributes ] && rm .gitattributes
44-
[ -d .github ] && rm -r .github
45-
[ -d .git ] && rm -r .git
4644
[ -f .gitignore ] && rm .gitignore
4745
[ -f phpcs.xml ] && rm phpcs.xml
4846
[ -f wpgulp.config.js ] && rm wpgulp.config.js
@@ -53,6 +51,9 @@ jobs:
5351
[ -f package-lock.json ] && rm package-lock.json
5452
[ -f readme.md ] && rm readme.md
5553
[ -f playwright.config.js ] && rm playwright.config.js
54+
[ -d .cursor ] && rm -r .cursor
55+
[ -d .github ] && rm -r .github
56+
[ -d .git ] && rm -r .git
5657
[ -d assets/sass ] && rm -r assets/sass
5758
[ -d assets/js/src ] && rm -r assets/js/src
5859
[ -d node_modules ] && rm -r node_modules

0 commit comments

Comments
 (0)