-
Notifications
You must be signed in to change notification settings - Fork 15
52 lines (40 loc) · 2.44 KB
/
test-environment-deployment.yml
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
# Purpose: Deploy the backend to the test environment.
# Name of the workflow
name: Deploy to Test Environment
on:
push:
branches:
- main # Trigger the workflow when a push event occurs on the main branch
jobs:
build: # Define the "build" job
runs-on: ubuntu-latest # Run the job on the latest version of Ubuntu
steps: # List of steps to execute within the job
- name: Update package cache # Step to update the package cache
run: sudo apt-get update
- name: Checkout code # Step to check out the code from the repository
uses: actions/checkout@v3
- name: Set up Java # Step to set up the Java environment
uses: actions/setup-java@v3
with:
java-version: 17 # Specify Java 17 as the version
distribution: 'zulu' # Use the 'zulu' distribution of Java
- name: Set up Docker # Step to set up the Docker environment
uses: actions/hello-world-docker-action@v2
- name: Install Maven # Step to install Maven
run: sudo apt-get install -y maven
- name: Copy settings.xml file from template # Step to create a new 'settings.xml' file by copying the 'template-settings.xml'
run: cp template-settings.xml settings.xml
- name: Replace username in settings.xml # Step to replace the placeholder username in settings.xml
run: sed 's|'{YOUR_GITHUB_USERNAME}'|'${{ secrets.GH_USERNAME }}'|g' settings.xml >> temp-settings.xml ; rm settings.xml ; mv temp-settings.xml settings.xml
- name: Replace access token in settings.xml # Step to replace the placeholder access token in settings.xml
run: sed 's|'{YOUR_PERSONAL_GITHUB_ACCESS_TOKEN}'|'${{ secrets.GH_USER_ACCESS_TOKEN }}'|g' settings.xml >> temp-settings.xml ; rm settings.xml ; mv temp-settings.xml settings.xml
- name: Build with Maven # Step to build the application using Maven with the provided settings.xml configuration file
run: mvn --settings settings.xml clean install
- name: Deploy to server # Step to deploy the application to the server using the deploy.sh script with the specified environment variables
env:
AWS_PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }}
AWS_USERNAME: ${{ secrets.AWS_USERNAME }}
AWS_TEST_ENVIRONMENT_IP: ${{ secrets.AWS_TEST_ENVIRONMENT_IP }}
AWS_BE_APP_PATH: ${{ secrets.AWS_BE_APP_PATH }}
GH_TEST_DEPLOYMENT_BRANCH: main
run: bash .github/workflows/test/deploy.sh