Skip to content

Commit a9999c6

Browse files
authored
Merge pull request #4 from inpsyde/delete-conf-file
2 parents 72a9cf5 + f3de0b3 commit a9999c6

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.github/workflows/test-setup-wireguard.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ jobs:
6464
run: |
6565
curl --fail http://192.168.4.1
6666
67+
- name: Verify Config File Removal
68+
run: |
69+
if [ -f wg0.conf ]; then
70+
echo "Error: wg0.conf file exists when it should have been deleted."
71+
exit 1
72+
else
73+
echo "Success: wg0.conf file has been deleted."
74+
fi
75+
6776
test-invalid-config:
6877
name: Test with Invalid Configuration
6978
needs: generate-config
@@ -100,3 +109,13 @@ jobs:
100109
run: |
101110
echo "Test failed: action did not fail as expected."
102111
exit 1
112+
113+
- name: Verify Config File Removal on Failure
114+
if: ${{ steps.invalid_test.outcome == 'failure' }}
115+
run: |
116+
if [ -f wg0.conf ]; then
117+
echo "Error: wg0.conf file exists after action failure."
118+
exit 1
119+
else
120+
echo "Success: wg0.conf file does not exist after action failure."
121+
fi

setup-wireguard/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ runs:
1313
echo "${{ inputs.wireguard-configuration }}" > wg0.conf
1414
sudo chmod 600 wg0.conf
1515
16+
# Ensure wg0.conf is deleted on exit
17+
trap 'rm -f wg0.conf' EXIT
18+
1619
if grep -E '^\s*(PreUp|PostUp|PreDown|PostDown)\s*=' wg0.conf >/dev/null; then
1720
echo "Error: Configuration contains disallowed and potentially dangerous directives (PreUp, PostUp, PreDown, PostDown)."
1821
exit 1

0 commit comments

Comments
 (0)