-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (79 loc) · 2.56 KB
/
test.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
name: "build-test"
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
- "releases/*"
jobs:
build: # make sure build/ci work properly
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build
run: yarn all
test: # make sure the action works on a clean machine without building
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: dummy
AWS_SECRET_ACCESS_KEY: dummy
AWS_REGION: us-east-1
AWS_SECRETS_MANAGER_ENDPOINT_URL: http://localhost:4566
services:
localstack:
image: localstack/localstack
env:
SERVICES: secretsmanager
ports:
- 4566:4566
steps:
- uses: actions/checkout@v3
- name: Setup some sample credentials
run: |
aws --endpoint-url="$AWS_SECRETS_MANAGER_ENDPOINT_URL" secretsmanager create-secret \
--name mysecret --secret-string '{"SECRET_KEY":"SECRET_VALUE","SECRET_KEY2":"SECRET_VALUE2"}'
- name: Configure AWS Secrets Manager
id: secrets
uses: ./
with:
secret-id: mysecret
exporters: env,output,file
- name: Check environment variables are set
run: |
if [ -z "$SECRET_KEY" ]; then
echo "SECRET_KEY is not set"
exit 1
fi
if [ -z "$SECRET_KEY2" ]; then
echo "SECRET_KEY2 is not set"
exit 1
fi
- name: Check output variables are set
run: |
if [ "${{ steps.secrets.outputs.SECRET_KEY }}" != "SECRET_VALUE" ]; then
echo "SECRET_KEY is not set"
exit 1
fi
if [ "${{ steps.secrets.outputs.SECRET_KEY2 }}" != "SECRET_VALUE2" ]; then
echo "SECRET_KEY2 is not set"
exit 1
fi
- name: Check file is set
run: |
EXPECTED_FILE_CONTENT="SECRET_KEY=SECRET_VALUE
SECRET_KEY2=SECRET_VALUE2"
IFS= read -rd '' ACTUAL_FILE_CONTENT < ./.env || true
if [ "$EXPECTED_FILE_CONTENT" != "$ACTUAL_FILE_CONTENT" ]; then
echo -e "Env file is not what was expected"
diff -u <(echo "$EXPECTED_FILE_CONTENT") <(echo "$ACTUAL_FILE_CONTENT")
exit 1
fi