Skip to content

Commit 801ccb2

Browse files
committed
WIP
1 parent 3ba26fd commit 801ccb2

File tree

2 files changed

+57
-23
lines changed

2 files changed

+57
-23
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Secrets Bundle Parse
2+
description: |
3+
Parses a secrets bundle and exports each secret as an environment variable.
4+
Requires `jq`.
5+
6+
inputs:
7+
secrets:
8+
required: true
9+
description: |
10+
Secret bundle created by block scalar `|` and `toJSON` which is used to
11+
encode each secret into 1 line, allowing line-based separation per secret.
12+
13+
SECRETS: |
14+
SECRET1=$${{ toJSON(secrets.SECRET1) }}
15+
SECRET2=$${{ toJSON(secrets.SECRET2) }}
16+
SECRET3=$${{ toJSON(secrets.SECRET3) }}
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Export Secrets
22+
shell: bash
23+
env:
24+
SECRETS: ${{ inputs.secrets }}
25+
run: |
26+
if ! type jq &> /dev/null; then
27+
echo 'jq is not installed. Please install jq to proceed.'
28+
exit 1
29+
fi
30+
delimiter="EOF-$RANDOM"
31+
while IFS= read -r line; do
32+
if [ -z "$line" ]; then
33+
continue
34+
fi
35+
key="${line%%=*}"
36+
json_value="${line#*=}"
37+
value="$(jq -r '.' <<< "$json_value")"
38+
# Mask the value from the logs
39+
echo "::add-mask::$value"
40+
{
41+
printf "%s<<%s\n" "$key" "$delimiter"
42+
printf "%s\n" "$value"
43+
printf "%s\n" "$delimiter"
44+
} >> "$GITHUB_ENV"
45+
done <<< "$SECRETS"

.github/workflows/application-js-cloudflare-feature.yml

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ name: "CI / Application JS Cloudflare Feature"
33
on:
44
workflow_call:
55
inputs:
6-
APP_NAME:
6+
appHostname:
77
type: string
88
required: true
9-
VAR1:
9+
ref:
1010
type: string
11+
default: master
12+
description: >
13+
Reference used for this repository, so we can re-use it when
14+
referencing local actions, and avoid having to checkout this
15+
repository separately.
16+
1117
secrets:
1218
GH_TOKEN:
1319
required: true
@@ -39,27 +45,10 @@ jobs:
3945
feature-debug:
4046
name: "Feature / Debug"
4147
runs-on: ubuntu-latest
42-
env:
43-
DEPLOY_SECRETS: ${{ secrets.DEPLOY_SECRETS }}
4448
steps:
45-
- name: Debug Something
46-
run: |
47-
delimiter="EOF-$(date +%s%N)"
48-
while IFS= read -r line; do
49-
if [ -z "$line" ]; then
50-
continue
51-
fi
52-
key="$(cut -d'=' -f1 <<< "$line")"
53-
json_value="$(cut -d'=' -f2- <<< "$line")"
54-
value="$(jq -r '.' <<< "$json_value")"
55-
# Mask the value from the logs
56-
sed 's/^ */::add-mask::/' <<< "$value"
57-
{
58-
printf "$key<<$delimiter\n"
59-
printf "$value\n"
60-
printf "$delimiter\n"
61-
} >> "$GITHUB_ENV"
62-
done <<< "$DEPLOY_SECRETS"
49+
- uses: MatrixAI/.github/.github/actions/secrets-parse@${{inputs.ref}}
50+
with:
51+
secrets: ${{ secrets.DEPLOY_SECRETS }}
6352
- name: Next Part
6453
run: |
6554
echo $SECRET1
@@ -132,7 +121,7 @@ jobs:
132121
# - name: Run deployment
133122
# env:
134123
# name: "feature/${{ github.ref_name }}"
135-
# url: "https://${{ github.ref_name }}.dev.${{ inputs.APP_NAME }}"
124+
# url: "https://${{ github.ref_name }}.dev.${{ inputs.appHostname }}"
136125
# run: |
137126
# echo 'Perform service deployment for feature'
138127
# echo "$SECRET1"

0 commit comments

Comments
 (0)