forked from oNaiPs/secrets-to-env-action
-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (111 loc) · 4.27 KB
/
e2e.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
name: "e2e"
on:
push:
branches:
- main
- "releases/*"
jobs:
test-exclude:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Export secrets to env variables (with exclude)
uses: ./
with:
secrets: ${{ toJSON(secrets) }}
exclude: non-existent,SECRET_2
env:
SECRET_1: 1234 # Should show override warning
- name: Verify secrets to env variables (with exclude)
run: |
[[ "${SECRET_1}" != "VALUE_1" ]] && echo "Could not export SECRET_1 secret, value is ${SECRET_1}" && exit 1
[[ "${SECRET_2}" != "" ]] && echo "SECRET_2 should be unset, got ${SECRET_2}" && exit 1
[[ "${SECRET_3}" != "VALUE_3" ]] && echo "Could not export SECRET_3 secret, value is ${SECRET_3}" && exit 1
true
shell: bash
test-include-prefix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Export secrets to env variables (with prefix, include)
uses: ./
with:
prefix: PREF_
secrets: ${{ toJSON(secrets) }}
include: non-existent, SECRET_1
- name: Verify secrets to env variables (with prefix, include)
run: |
[[ "${SECRET_1}" != "" ]] && echo "SECRET_1 should be unset, got ${SECRET_1}" && exit 1
[[ "${PREF_SECRET_1}" != "VALUE_1" ]] && echo "Could not export SECRET_1 secret, value is ${SECRET_1}" && exit 1
[[ "${SECRET_2}" != "" ]] && echo "SECRET_2 should be unset, got ${SECRET_2}" && exit 1
[[ "${SECRET_3}" != "" ]] && echo "SECRET_3 should be unset, got ${SECRET_3}" && exit 1
[[ "${PREF_SECRET_2}" != "" ]] && echo "PREF_SECRET_2 should be unset, got ${PREF_SECRET_2}" && exit 1
[[ "${PREF_SECRET_3}" != "" ]] && echo "PREF_SECRET_3 should be unset, got ${PREF_SECRET_3}" && exit 1
true
shell: bash
test-override:
runs-on: ubuntu-latest
env:
SECRET_1: DONT_OVERRIDE
steps:
- uses: actions/checkout@v4
- name: Export secrets to env variables (override)
uses: ./
with:
override: false
secrets: ${{ toJSON(secrets) }}
- name: Verify secrets to env variables (override)
run: |
[[ "${SECRET_1}" != "DONT_OVERRIDE" ]] && echo "Override test failed" && exit 1
true
shell: bash
test-convert:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Export secrets to env variables (convert)
uses: ./
with:
convert: pascal
secrets: ${{ toJSON(secrets) }}
- name: Verify secrets to env variables (convert)
run: |
[[ "${Secret_1}" != "VALUE_1" ]] && echo "Could not export Secret_1 secret, value is ${Secret_1}" && exit 1
[[ "${Secret_2}" != "VALUE_2" ]] && echo "Could not export Secret_2 secret, value is ${Secret_2}" && exit 1
[[ "${Secret_3}" != "VALUE_3" ]] && echo "Could not export Secret_3 secret, value is ${Secret_3}" && exit 1
true
shell: bash
test-convert-prefix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Export secrets to env variables (starts with, include)
uses: ./
with:
prefix: MY_
convert_prefix: false
convert: lower
secrets: ${{ toJSON(secrets) }}
- name: Verify secrets to env variables (starts with, include)
run: |
[[ "${MY_secret_1}" != "VALUE_1" ]] && echo "Could not export MY_secret_1 secret, value is ${MY_secret_1}" && exit 1
[[ "${MY_secret_2}" != "VALUE_2" ]] && echo "Could not export MY_secret_2 secret, value is ${MY_secret_2}" && exit 1
[[ "${MY_secret_3}" != "VALUE_3" ]] && echo "Could not export MY_secret_3 secret, value is ${MY_secret_3}" && exit 1
true
shell: bash
# These jobs always fail, for now we just use it to check if the output is the expected
test-errors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Bad secrets
uses: ./
with:
secrets: asdf
continue-on-error: true
- name: Bad convert value
uses: ./
with:
convert: bad
secrets: ${{ toJSON(secrets) }}
continue-on-error: true