-
Notifications
You must be signed in to change notification settings - Fork 1.8k
105 lines (90 loc) · 3.08 KB
/
aws-terraform-integration-tests.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: aws-tests
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'hazelcast/src/main/java/com/hazelcast/aws/**'
- 'hazelcast/pom.xml'
- '.github/terraform/aws/**'
jobs:
build:
defaults:
run:
shell: bash
env:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8' ]
architecture: [ 'x64' ]
distribution: [ 'adopt' ]
steps:
# SET UP JDK
- name: Setup JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
architecture: ${{ matrix.architecture }}
distribution: ${{ matrix.distribution }}
- run: java -version
- run : mkdir ~/lib
# BUILD HAZELCAST AWS SNAPSHOT
- uses: actions/checkout@v2.3.4
with:
path: hazelcast
- name: Build hazelcast jar
run: |
cd hazelcast
mvn clean install -DskipTests -Dcheckstyle.skip
echo "Hazelcast jar is: " hazelcast/target/hazelcast-*-SNAPSHOT.jar
cp hazelcast/target/hazelcast-*-SNAPSHOT.jar ~/lib/hazelcast.jar
#BUILD TERRAFORM
- name : Set-up Terraform
uses: hashicorp/setup-terraform@v1.3.2
with:
terraform_version: 0.13.0
- name: Create unique prefix for resources
run: |
sed -i -e "s/SET_PREFIX/${GITHUB_WORKFLOW}-${GITHUB_RUN_ID}/g" hazelcast/.github/terraform/aws/hazelcast.yaml
sed -i -e "s/SET_PREFIX/\"${GITHUB_WORKFLOW}-${GITHUB_RUN_ID}\"/g" hazelcast/.github/terraform/aws/terraform.tfvars
- name: Terraform Init
run: cd hazelcast/.github/terraform/aws && terraform init
- name: Terraform Format
run: cd hazelcast/.github/terraform/aws && terraform fmt
- name: Generate SSH keys
id: ssh
run: |
ssh-keygen -t rsa -b 4096 -C "devOpsHazelcast@hazelcast.com" -f id_rsa -P "" 1>/dev/null
ssh_key=$(cat id_rsa)
echo 'SSH_KEY<<EOF' >> $GITHUB_ENV
echo "$ssh_key" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
ssh_key_public=$(cat id_rsa.pub)
echo 'SSH_KEY_PUBLIC<<EOF' >> $GITHUB_ENV
echo "$ssh_key_public" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Install private key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ env.SSH_KEY }}
name: id_rsa
known_hosts: " "
- name: Install public key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ env.SSH_KEY_PUBLIC }}
name: id_rsa.pub
known_hosts: " "
- name: Terraform Apply
run: |
cd hazelcast/.github/terraform/aws && terraform apply -auto-approve
- name: Terraform Destroy
if: ${{ always() }}
run: |
cd hazelcast/.github/terraform/aws && terraform destroy -auto-approve