-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (110 loc) · 3.2 KB
/
ci.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: ci
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: package.json
cache: npm
- name: Run npm ci
run: npm ci
- name: Build
run: npm run build
- name: Check diff
run: |
if ! git diff --no-patch --exit-code; then
echo Diff found 1>&2
exit 1
fi
lint:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: package.json
cache: npm
- name: Run npm ci
run: npm ci
- name: Run ESLint
run: npm run lint
format:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: package.json
cache: npm
- name: Run npm ci
run: npm ci
- name: Run Prettier format check
run: npm run format:check
test-node:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: package.json
cache: npm
- name: Run npm ci
run: npm ci
- name: Test
run: npm test
test-action:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run export-secrets
uses: ./
with:
secrets: |
{
"FOO": "foo",
"TF_VAR_FOO": "tf-var-foo",
"TF_TOKEN_EXAMPLE_COM": "tf-token-example-com"
}
downcase-tf-var: true
downcase-tf-token: true
- name: Check environment variables
run: |
FAILED=''
assert_env() {
local KEY="$1"
local EXPECTED="$2"
local ACTUAL="${!KEY}"
if [[ "$EXPECTED" = "$ACTUAL" ]]; then
echo "PASSED: $KEY"
else
echo "FAILED: $KEY" 1>&2
echo " expected: $EXPECTED" 1>&2
echo " actual: $ACTUAL" 1>&2
FAILED='true'
fi
}
assert_env 'FOO' 'foo'
assert_env 'TF_VAR_FOO' ''
assert_env 'TF_VAR_foo' 'tf-var-foo'
assert_env 'TF_TOKEN_EXAMPLE_COM' ''
assert_env 'TF_TOKEN_example_com' 'tf-token-example-com'
if [[ -n "$FAILED" ]]; then
echo "Test failed" 1>&2
exit 1
fi