Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ jobs:
name: Deploy
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
env:
RUNNER_IP: ""
steps:
# 1. Récupérer l'IP publique du runner
- name: Get runner public IP
id: ip
run: echo "ip=$(curl -s https://api.ipify.org)" >> $GITHUB_OUTPUT
run: echo "RUNNER_IP=$(curl -s https://api.ipify.org)" >> $GITHUB_ENV
# 2. Ajouter l'IP en liste blanche sur le pare-feu o2switch
- name: Whitelist runner IP on o2switch firewall
run: |
curl -sm 45 \
-H "Authorization: cpanel ${{ secrets.CPANEL_USERNAME }}:${{ secrets.CPANEL_API_TOKEN }}" \
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/add?address=${{ steps.ip.outputs.ip }}&port=22"
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/add?address=${{ env.RUNNER_IP }}&port=22"
# 3. Courte pause pour que la règle firewall soit effective
- name: Wait for firewall rule to propagate
run: sleep 5
Expand All @@ -48,6 +50,10 @@ jobs:
- name: Remove runner IP from whitelist
if: always()
run: |
echo "Removing $RUNNER_IP"
curl -sm 45 \
-H "Authorization: cpanel ${{ secrets.CPANEL_USERNAME }}:${{ secrets.CPANEL_API_TOKEN }}" \
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/remove?address=${{ steps.ip.outputs.ip }}&port=22"
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/remove?address=$RUNNER_IP&port=22&direction=in"
curl -sm 45 \
-H "Authorization: cpanel ${{ secrets.CPANEL_USERNAME }}:${{ secrets.CPANEL_API_TOKEN }}" \
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/remove?address=$RUNNER_IP&port=22&direction=out"
12 changes: 9 additions & 3 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ jobs:
name: Deploy
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
env:
RUNNER_IP: ""
steps:
# 1. Récupérer l'IP publique du runner
- name: Get runner public IP
id: ip
run: echo "ip=$(curl -s https://api.ipify.org)" >> $GITHUB_OUTPUT
run: echo "RUNNER_IP=$(curl -s https://api.ipify.org)" >> $GITHUB_ENV
# 2. Ajouter l'IP en liste blanche sur le pare-feu o2switch
- name: Whitelist runner IP on o2switch firewall
run: |
curl -sm 45 \
-H "Authorization: cpanel ${{ secrets.CPANEL_USERNAME }}:${{ secrets.CPANEL_API_TOKEN }}" \
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/add?address=${{ steps.ip.outputs.ip }}&port=22"
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/add?address=${{ env.RUNNER_IP }}&port=22"
# 3. Courte pause pour que la règle firewall soit effective
- name: Wait for firewall rule to propagate
run: sleep 5
Expand All @@ -48,6 +50,10 @@ jobs:
- name: Remove runner IP from whitelist
if: always()
run: |
echo "Removing $RUNNER_IP"
curl -sm 45 \
-H "Authorization: cpanel ${{ secrets.CPANEL_USERNAME }}:${{ secrets.CPANEL_API_TOKEN }}" \
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/remove?address=${{ steps.ip.outputs.ip }}&port=22"
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/remove?address=$RUNNER_IP&port=22&direction=in"
curl -sm 45 \
-H "Authorization: cpanel ${{ secrets.CPANEL_USERNAME }}:${{ secrets.CPANEL_API_TOKEN }}" \
"https://${{ secrets.CPANEL_HOST }}:2083/execute/SshWhitelist/remove?address=$RUNNER_IP&port=22&direction=out"
Loading