mirror of
https://github.com/actions/cache.git
synced 2026-01-31 20:05:00 +01:00
Rewrite and simplify
This commit is contained in:
64
.github/workflows/workflow.yml
vendored
64
.github/workflows/workflow.yml
vendored
@@ -90,15 +90,45 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ubuntu:latest
|
image: ubuntu:latest
|
||||||
options: --dns 127.0.0.1
|
options: --cap-add=NET_ADMIN --dns 127.0.0.1
|
||||||
services:
|
services:
|
||||||
squid-proxy:
|
squid-proxy:
|
||||||
image: ubuntu/squid:latest
|
image: ubuntu/squid:latest
|
||||||
ports:
|
ports:
|
||||||
- 3128:3128
|
- 3128:3128
|
||||||
env:
|
env:
|
||||||
|
http_proxy: http://squid-proxy:3128
|
||||||
https_proxy: http://squid-proxy:3128
|
https_proxy: http://squid-proxy:3128
|
||||||
steps:
|
steps:
|
||||||
|
- name: Install iptables
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y iptables
|
||||||
|
- name: Block direct traffic (enforce proxy usage)
|
||||||
|
run: |
|
||||||
|
# Get the squid-proxy container IP
|
||||||
|
PROXY_IP=$(getent hosts squid-proxy | awk '{ print $1 }')
|
||||||
|
echo "Proxy IP: $PROXY_IP"
|
||||||
|
|
||||||
|
# Allow loopback traffic
|
||||||
|
iptables -A OUTPUT -o lo -j ACCEPT
|
||||||
|
|
||||||
|
# Allow traffic to the proxy container
|
||||||
|
iptables -A OUTPUT -d $PROXY_IP -j ACCEPT
|
||||||
|
|
||||||
|
# Allow established connections
|
||||||
|
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
|
||||||
|
|
||||||
|
# Allow DNS (needed for initial resolution)
|
||||||
|
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
|
||||||
|
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
|
||||||
|
|
||||||
|
# Block all other outbound traffic (HTTP/HTTPS)
|
||||||
|
iptables -A OUTPUT -p tcp --dport 80 -j REJECT
|
||||||
|
iptables -A OUTPUT -p tcp --dport 443 -j REJECT
|
||||||
|
|
||||||
|
# Log the iptables rules for debugging
|
||||||
|
iptables -L -v -n
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
- name: Generate files
|
- name: Generate files
|
||||||
@@ -114,15 +144,45 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ubuntu:latest
|
image: ubuntu:latest
|
||||||
options: --dns 127.0.0.1
|
options: --cap-add=NET_ADMIN --dns 127.0.0.1
|
||||||
services:
|
services:
|
||||||
squid-proxy:
|
squid-proxy:
|
||||||
image: ubuntu/squid:latest
|
image: ubuntu/squid:latest
|
||||||
ports:
|
ports:
|
||||||
- 3128:3128
|
- 3128:3128
|
||||||
env:
|
env:
|
||||||
|
http_proxy: http://squid-proxy:3128
|
||||||
https_proxy: http://squid-proxy:3128
|
https_proxy: http://squid-proxy:3128
|
||||||
steps:
|
steps:
|
||||||
|
- name: Install iptables
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y iptables
|
||||||
|
- name: Block direct traffic (enforce proxy usage)
|
||||||
|
run: |
|
||||||
|
# Get the squid-proxy container IP
|
||||||
|
PROXY_IP=$(getent hosts squid-proxy | awk '{ print $1 }')
|
||||||
|
echo "Proxy IP: $PROXY_IP"
|
||||||
|
|
||||||
|
# Allow loopback traffic
|
||||||
|
iptables -A OUTPUT -o lo -j ACCEPT
|
||||||
|
|
||||||
|
# Allow traffic to the proxy container
|
||||||
|
iptables -A OUTPUT -d $PROXY_IP -j ACCEPT
|
||||||
|
|
||||||
|
# Allow established connections
|
||||||
|
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
|
||||||
|
|
||||||
|
# Allow DNS (needed for initial resolution)
|
||||||
|
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
|
||||||
|
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
|
||||||
|
|
||||||
|
# Block all other outbound traffic (HTTP/HTTPS)
|
||||||
|
iptables -A OUTPUT -p tcp --dport 80 -j REJECT
|
||||||
|
iptables -A OUTPUT -p tcp --dport 443 -j REJECT
|
||||||
|
|
||||||
|
# Log the iptables rules for debugging
|
||||||
|
iptables -L -v -n
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
- name: Restore cache
|
- name: Restore cache
|
||||||
|
|||||||
Reference in New Issue
Block a user