Skip to content

Commit 7747ea1

Browse files
authored
Create compare-opta-versions.yml (#351)
1 parent 1f99527 commit 7747ea1

1 file changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Create-n-Destoy AWS Resources using Different Opta Versions
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version1:
7+
description: 'Opta Version 1'
8+
required: true
9+
version2:
10+
description: 'Opta Version 2'
11+
required: true
12+
13+
jobs:
14+
compare-opta-versions:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Pin terraform version
18+
uses: hashicorp/setup-terraform@v1
19+
with:
20+
terraform_version: 1.0.0
21+
terraform_wrapper: false
22+
23+
- name: Limit concurrency to 1.
24+
uses: softprops/turnstyle@v1
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.ALL_GITHUB_TOKEN }}
27+
28+
- name: Checkout runx-infra repo
29+
uses: actions/checkout@v2
30+
with:
31+
repository: "run-x/runx-infra"
32+
path: "runx-infra"
33+
ssh-key: ${{ secrets.SSH_KEY }}
34+
35+
- name: Checkout test-service repo
36+
uses: actions/checkout@v2
37+
with:
38+
repository: "run-x/test-service"
39+
path: "test-service"
40+
ssh-key: ${{ secrets.SSH_KEY }}
41+
42+
- name: Setup ssh
43+
uses: webfactory/ssh-agent@v0.4.1
44+
with:
45+
ssh-private-key: ${{ secrets.SSH_KEY }}
46+
47+
- name: Configure AWS credentials
48+
uses: aws-actions/configure-aws-credentials@v1
49+
with:
50+
aws-access-key-id: ${{ secrets.AWS_OPTA_CI_ACCESS_KEY }}
51+
aws-secret-access-key: ${{ secrets.AWS_OPTA_CI_SECRET_KEY }}
52+
aws-region: us-east-1
53+
54+
- name: Install Version 1 binary from Opta GitHub releases
55+
run: VERSION=${{ github.event.inputs.version1 }} /bin/bash -c "$(curl -fsSL https://docs.opta.dev/install.sh)"
56+
57+
- name: Check Opta Version Installed
58+
run: opta version
59+
60+
- name: Apply opta environment
61+
run: |
62+
OPTA_DISABLE_REPORTING=true opta apply \
63+
--config runx-infra/opta-ci/opta.yml \
64+
--auto-approve \
65+
--refresh
66+
67+
- name: Login to Amazon ECR
68+
id: login-ecr
69+
uses: aws-actions/amazon-ecr-login@v1
70+
71+
- name: Build test-service image
72+
run: docker build -t app:latest -f test-service/Dockerfile test-service/
73+
74+
- name: Set secret
75+
run: |
76+
OPTA_DISABLE_REPORTING=true opta secret update \
77+
--env ci \
78+
--config test-service/opta.yml \
79+
FAKE_SECRET foo
80+
81+
- name: Deploy test-service
82+
run: |
83+
OPTA_DISABLE_REPORTING=true opta deploy \
84+
--image app:latest \
85+
--env ci \
86+
--config test-service/opta.yml \
87+
--tag ${{ github.sha }} \
88+
--auto-approve
89+
90+
- name: View secret and check value
91+
run: |
92+
secret_value=$(OPTA_DISABLE_REPORTING=true opta secret view \
93+
--env ci \
94+
--config test-service/opta.yml \
95+
FAKE_SECRET | tail -1)
96+
echo "This was the found secret value: ${secret_value}"
97+
[[ "$secret_value" =~ .*"foo".* ]] || exit 1
98+
99+
- name: Install Version 2 binary from Opta GitHub releases
100+
run: VERSION=${{ github.event.inputs.version2 }} /bin/bash -c "$(curl -fsSL https://docs.opta.dev/install.sh)"
101+
102+
- name: Check Opta Version Installed
103+
run: opta version
104+
105+
- name: Deploy test-service
106+
run: |
107+
OPTA_DISABLE_REPORTING=true opta deploy \
108+
--image app:latest \
109+
--env ci \
110+
--config test-service/opta.yml \
111+
--tag ${{ github.sha }} \
112+
--auto-approve
113+
114+
- name: View secret and check value
115+
run: |
116+
secret_value=$(OPTA_DISABLE_REPORTING=true opta secret view \
117+
--env ci \
118+
--config test-service/opta.yml \
119+
FAKE_SECRET | tail -1)
120+
echo "This was the found secret value: ${secret_value}"
121+
[[ "$secret_value" =~ .*"foo".* ]] || exit 1
122+
123+
- name: Destroy environment (and test service)
124+
run: |
125+
yes | OPTA_DISABLE_REPORTING=true opta destroy \
126+
--env ci \
127+
--config test-service/opta.yml \
128+
--auto-approve
129+
yes | OPTA_DISABLE_REPORTING=true opta destroy \
130+
--config runx-infra/opta-ci/opta.yml \
131+
--auto-approve

0 commit comments

Comments
 (0)