@@ -11,15 +11,27 @@ name: Auto-builds Daily Cleanup
11
11
- cron : ' 1 0 * * *' # Runs the workflow every day at 00:01.
12
12
13
13
jobs :
14
- builds :
14
+ cleaning :
15
15
name : Delete builds for non existing branches
16
16
runs-on : ubuntu-22.04
17
17
18
18
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
+
19
24
# This action exposes GitHub environment variables to be used in subsequent steps.
20
25
- name : GitHub Environment Variables Action
21
26
uses :
FranzDiebold/[email protected]
22
27
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
+
23
35
# This step extracts the repository name from the full repository path and sets it as a PROJECT_NAME environment variable.
24
36
# e.g. if the repository is aThemes/merchant, the project name will be "merchant".
25
37
- name : Set Project Name
37
49
chmod 600 ~/.ssh/id_ed25519
38
50
chmod 700 ~/.ssh
39
51
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
+
40
56
# This step fetches the latest list of remote branches, formats the branch names, and saves them to a file named branches.txt.
41
57
# The formatting removes the "origin/" prefix and replaces slashes and dots with hyphens.
42
58
- name : Prepare list of branches
50
66
# This step connects to the staging server via SSH and lists the contents of the auto-builds directory for the current project.
51
67
# The list of auto-builds is saved to a file named auto-builds.txt.
52
68
- 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
54
70
55
71
# This step reads the auto-builds.txt file line by line.
56
72
# For each auto-build, it checks if a corresponding branch exists in the branches.txt file.
66
82
if ! grep -q "$dir" branches.txt
67
83
then
68
84
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"
70
86
fi
71
87
done < auto-builds.txt
0 commit comments