Skip to content

Commit 7e27b44

Browse files
committed
ci: Use intermediate environment variables for improved security
1 parent 0b19a42 commit 7e27b44

File tree

8 files changed

+46
-19
lines changed

8 files changed

+46
-19
lines changed

.github/actions/build-clio/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ runs:
2121

2222
- name: Build targets
2323
shell: bash
24+
env:
25+
CMAKE_TARGETS: ${{ inputs.targets }}
2426
run: |
2527
cd build
2628
cmake \
2729
--build . \
2830
--parallel "${{ steps.number_of_threads.outputs.threads_number }}" \
29-
--target ${{ inputs.targets }}
31+
--target ${CMAKE_TARGETS}

.github/actions/create-issue/action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ runs:
2828
- name: Create an issue
2929
id: create_issue
3030
shell: bash
31+
env:
32+
ISSUE_BODY: ${{ inputs.body }}
33+
ISSUE_ASSIGNEES: ${{ inputs.assignees }}
34+
ISSUE_LABELS: ${{ inputs.labels }}
35+
ISSUE_TITLE: ${{ inputs.title }}
3136
run: |
32-
echo -e '${{ inputs.body }}' > issue.md
37+
echo -e "${ISSUE_BODY}" > issue.md
3338
gh issue create \
34-
--assignee '${{ inputs.assignees }}' \
35-
--label '${{ inputs.labels }}' \
36-
--title '${{ inputs.title }}' \
39+
--assignee "${ISSUE_ASSIGNEES}" \
40+
--label "${ISSUE_LABELS}" \
41+
--title "${ISSUE_TITLE}" \
3742
--body-file ./issue.md \
3843
> create_issue.log
3944
created_issue="$(sed 's|.*/||' create_issue.log)"

.github/actions/get-threads-number/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ runs:
2929
- name: Shift and export number of threads
3030
id: number_of_threads_export
3131
shell: bash
32+
env:
33+
SUBTRACT_THREADS: ${{ inputs.subtract_threads }}
3234
run: |
3335
num_of_threads="${{ steps.mac_threads.outputs.num || steps.linux_threads.outputs.num }}"
34-
shift_by="${{ inputs.subtract_threads }}"
36+
shift_by="${SUBTRACT_THREADS}"
3537
shifted="$((num_of_threads - shift_by))"
3638
echo "num=$(( shifted > 1 ? shifted : 1 ))" >> $GITHUB_OUTPUT

.github/workflows/build-clio-docker-image.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ jobs:
5656
- name: Download Clio binary from url
5757
if: ${{ inputs.clio_server_binary_url != null }}
5858
shell: bash
59+
env:
60+
BINARY_URL: ${{ inputs.clio_server_binary_url }}
61+
BINARY_SHA256: ${{ inputs.binary_sha256 }}
5962
run: |
60-
wget "${{inputs.clio_server_binary_url}}" -P ./docker/clio/artifact/
61-
if [ "$(sha256sum ./docker/clio/clio_server | awk '{print $1}')" != "${{inputs.binary_sha256}}" ]; then
63+
wget "${BINARY_URL}" -P ./docker/clio/artifact/
64+
if [ "$(sha256sum ./docker/clio/clio_server | awk '{print $1}')" != "${BINARY_SHA256}" ]; then
6265
echo "Binary sha256 sum doesn't match"
6366
exit 1
6467
fi

.github/workflows/check-pr-title.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ jobs:
1717
custom_labels: '{"build":"build", "feat":"enhancement", "fix":"bug", "docs":"documentation", "test":"testability", "ci":"ci", "style":"refactoring", "refactor":"refactoring", "perf":"performance", "chore":"tooling"}'
1818

1919
- name: Check if message starts with upper-case letter
20+
env:
21+
PR_TITLE: ${{ github.event.pull_request.title }}
2022
run: |
21-
if [[ ! "${{ github.event.pull_request.title }}" =~ ^[a-z]+:\ [\[A-Z] ]]; then
23+
if [[ ! "${PR_TITLE}" =~ ^[a-z]+:\ [\[A-Z] ]]; then
2224
echo "Error: PR title must start with an upper-case letter."
2325
exit 1
2426
fi

.github/workflows/reusable-build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,14 @@ jobs:
221221
- name: Verify expected version
222222
if: ${{ inputs.expected_version != '' }}
223223
shell: bash
224+
env:
225+
INPUT_EXPECTED_VERSION: ${{ inputs.expected_version }}
224226
run: |
225227
set -e
226-
EXPECTED_VERSION="clio-${{ inputs.expected_version }}"
228+
EXPECTED_VERSION="clio-${INPUT_EXPECTED_VERSION}"
227229
actual_version=$(./build/clio_server --version)
228230
if [[ "$actual_version" != "$EXPECTED_VERSION" ]]; then
229-
echo "Expected version '$EXPECTED_VERSION', but got '$actual_version'"
231+
echo "Expected version '${EXPECTED_VERSION}', but got '${actual_version}'"
230232
exit 1
231233
fi
232234

.github/workflows/reusable-release.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ jobs:
6767

6868
- name: Create release notes
6969
shell: bash
70+
env:
71+
RELEASE_HEADER: ${{ inputs.header }}
7072
run: |
7173
echo "# Release notes" > "${RUNNER_TEMP}/release_notes.md"
7274
echo "" >> "${RUNNER_TEMP}/release_notes.md"
73-
printf '%s\n' "${{ inputs.header }}" >> "${RUNNER_TEMP}/release_notes.md"
75+
printf '%s\n' "${RELEASE_HEADER}" >> "${RUNNER_TEMP}/release_notes.md"
7476
7577
- name: Generate changelog
7678
shell: bash
@@ -95,18 +97,25 @@ jobs:
9597
- name: Remove current release and tag
9698
if: ${{ github.event_name != 'pull_request' && inputs.overwrite_release }}
9799
shell: bash
100+
env:
101+
RELEASE_VERSION: ${{ inputs.version }}
98102
run: |
99-
gh release delete ${{ inputs.version }} --yes || true
100-
git push origin :${{ inputs.version }} || true
103+
gh release delete "${RELEASE_VERSION}" --yes || true
104+
git push origin :"${RELEASE_VERSION}" || true
101105
102106
- name: Publish release
103107
if: ${{ github.event_name != 'pull_request' }}
104108
shell: bash
109+
env:
110+
RELEASE_VERSION: ${{ inputs.version }}
111+
PRERELEASE_OPTION: ${{ inputs.prerelease && '--prerelease' || '' }}
112+
RELEASE_TITLE: ${{ inputs.title }}
113+
DRAFT_OPTION: ${{ inputs.draft && '--draft' || '' }}
105114
run: |
106-
gh release create "${{ inputs.version }}" \
107-
${{ inputs.prerelease && '--prerelease' || '' }} \
108-
--title "${{ inputs.title }}" \
115+
gh release create "${RELEASE_VERSION}" \
116+
${PRERELEASE_OPTION} \
117+
--title "${RELEASE_TITLE}" \
109118
--target "${GITHUB_SHA}" \
110-
${{ inputs.draft && '--draft' || '' }} \
119+
${DRAFT_OPTION} \
111120
--notes-file "${RUNNER_TEMP}/release_notes.md" \
112121
./release_artifacts/clio_server*

.github/workflows/upload-conan-deps.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,6 @@ jobs:
9999

100100
- name: Upload Conan packages
101101
if: ${{ github.repository_owner == 'XRPLF' && github.event_name != 'pull_request' && github.event_name != 'schedule' }}
102-
run: conan upload "*" -r=xrplf --confirm ${{ github.event.inputs.force_upload == 'true' && '--force' || '' }}
102+
env:
103+
FORCE_OPTION: ${{ github.event.inputs.force_upload == 'true' && '--force' || '' }}
104+
run: conan upload "*" -r=xrplf --confirm ${FORCE_OPTION}

0 commit comments

Comments
 (0)