forked from anmolnagpal/devops-machine
-
Notifications
You must be signed in to change notification settings - Fork 4
39 lines (28 loc) · 1.18 KB
/
sanity-check.yaml
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
name: Sanity Checks
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build the application image
run: docker build -t clouddrove/devops:0.0.${{ github.run_number }} -f .docker/Dockerfile .
- name: Bring container up and running
run: docker run --name devops -d clouddrove/devops:0.0.${{ github.run_number }}
- name: Wait for container to boot up
run: sleep 10
- name: Sanity check
run: |
# Get the latest versions
LATEST_TERRAFORM_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r .current_version)
# Get the installed versions
INSTALLED_TERRAFORM_VERSION=$(docker exec devops terraform version -json | jq -r .terraform_version)
# Compare versions
if [ "$LATEST_TERRAFORM_VERSION" != "$INSTALLED_TERRAFORM_VERSION" ]; then
echo "Terraform version mismatch: expected $LATEST_TERRAFORM_VERSION, got $INSTALLED_TERRAFORM_VERSION"
exit 1
fi