fix: address shellcheck warnings and improve script robustness #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y ufw curl shellcheck | |
- name: Run ShellCheck | |
run: | | |
shellcheck cloudflare-ufw-updater.sh | |
- name: Prepare environment for tests | |
run: | | |
# Mock UFW for testing | |
sudo mv /usr/sbin/ufw /usr/sbin/ufw.real || true | |
sudo touch /usr/sbin/ufw | |
sudo chmod +x /usr/sbin/ufw | |
- name: Run tests | |
run: | | |
# Run the script with test arguments | |
./cloudflare-ufw-updater.sh | |
./cloudflare-ufw-updater.sh --restore | |
- name: Restore environment | |
if: always() | |
run: | | |
# Restore original UFW | |
sudo mv /usr/sbin/ufw.real /usr/sbin/ufw || true |