mirror of
https://github.com/actions/cache.git
synced 2026-06-14 17:04:10 +08:00
Compare commits
2 Commits
dependabot
...
ad3cd831ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad3cd831ad | ||
|
|
028d01341f |
6
.github/workflows/codeql.yml
vendored
6
.github/workflows/codeql.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v4
|
uses: github/codeql-action/init@v3
|
||||||
# Override language selection by uncommenting this and choosing your languages
|
# Override language selection by uncommenting this and choosing your languages
|
||||||
# with:
|
# with:
|
||||||
# languages: go, javascript, csharp, python, cpp, java, ruby
|
# languages: go, javascript, csharp, python, cpp, java, ruby
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below).
|
# If this step fails, then you should remove it and run the build manually (see below).
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v4
|
uses: github/codeql-action/autobuild@v3
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||||
@@ -42,4 +42,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v4
|
uses: github/codeql-action/analyze@v3
|
||||||
|
|||||||
146
.github/workflows/workflow.yml
vendored
146
.github/workflows/workflow.yml
vendored
@@ -90,86 +90,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ubuntu:latest
|
image: ubuntu:latest
|
||||||
options: --cap-add=NET_ADMIN
|
options: --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: Wait for proxy to be ready
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "Waiting for squid proxy to be ready..."
|
|
||||||
echo "Resolving squid-proxy hostname:"
|
|
||||||
getent hosts squid-proxy || echo "DNS resolution failed"
|
|
||||||
for i in $(seq 1 30); do
|
|
||||||
if (echo > /dev/tcp/squid-proxy/3128) 2>/dev/null; then
|
|
||||||
echo "Proxy is ready!"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "Attempt $i: Proxy not ready, waiting..."
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
echo "Proxy failed to become ready"
|
|
||||||
exit 1
|
|
||||||
env:
|
|
||||||
http_proxy: ""
|
|
||||||
https_proxy: ""
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y iptables curl
|
|
||||||
- name: Verify proxy is working
|
|
||||||
run: |
|
|
||||||
echo "Testing proxy connectivity..."
|
|
||||||
curl -s -o /dev/null -w "%{http_code}" --proxy http://squid-proxy:3128 http://github.com || true
|
|
||||||
echo "Proxy verification complete"
|
|
||||||
- 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: Verify direct HTTPS is blocked
|
|
||||||
run: |
|
|
||||||
echo "Testing that direct HTTPS requests fail..."
|
|
||||||
if curl --noproxy '*' -s --connect-timeout 5 https://github.com > /dev/null 2>&1; then
|
|
||||||
echo "ERROR: Direct HTTPS request succeeded - blocking is not working!"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "SUCCESS: Direct HTTPS request was blocked as expected"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Testing that HTTPS through proxy succeeds..."
|
|
||||||
if curl --proxy http://squid-proxy:3128 -s --connect-timeout 10 https://github.com > /dev/null 2>&1; then
|
|
||||||
echo "SUCCESS: HTTPS request through proxy succeeded"
|
|
||||||
else
|
|
||||||
echo "ERROR: HTTPS request through proxy failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
- name: Generate files
|
- name: Generate files
|
||||||
@@ -185,86 +114,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ubuntu:latest
|
image: ubuntu:latest
|
||||||
options: --cap-add=NET_ADMIN
|
options: --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: Wait for proxy to be ready
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "Waiting for squid proxy to be ready..."
|
|
||||||
echo "Resolving squid-proxy hostname:"
|
|
||||||
getent hosts squid-proxy || echo "DNS resolution failed"
|
|
||||||
for i in $(seq 1 30); do
|
|
||||||
if (echo > /dev/tcp/squid-proxy/3128) 2>/dev/null; then
|
|
||||||
echo "Proxy is ready!"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "Attempt $i: Proxy not ready, waiting..."
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
echo "Proxy failed to become ready"
|
|
||||||
exit 1
|
|
||||||
env:
|
|
||||||
http_proxy: ""
|
|
||||||
https_proxy: ""
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y iptables curl
|
|
||||||
- name: Verify proxy is working
|
|
||||||
run: |
|
|
||||||
echo "Testing proxy connectivity..."
|
|
||||||
curl -s -o /dev/null -w "%{http_code}" --proxy http://squid-proxy:3128 http://github.com || true
|
|
||||||
echo "Proxy verification complete"
|
|
||||||
- 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: Verify direct HTTPS is blocked
|
|
||||||
run: |
|
|
||||||
echo "Testing that direct HTTPS requests fail..."
|
|
||||||
if curl --noproxy '*' -s --connect-timeout 5 https://github.com > /dev/null 2>&1; then
|
|
||||||
echo "ERROR: Direct HTTPS request succeeded - blocking is not working!"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "SUCCESS: Direct HTTPS request was blocked as expected"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Testing that HTTPS through proxy succeeds..."
|
|
||||||
if curl --proxy http://squid-proxy:3128 -s --connect-timeout 10 https://github.com > /dev/null 2>&1; then
|
|
||||||
echo "SUCCESS: HTTPS request through proxy succeeded"
|
|
||||||
else
|
|
||||||
echo "ERROR: HTTPS request through proxy failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
- name: Restore cache
|
- name: Restore cache
|
||||||
|
|||||||
37
examples.md
37
examples.md
@@ -40,6 +40,7 @@
|
|||||||
- [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods)
|
- [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods)
|
||||||
- [Swift - Swift Package Manager](#swift---swift-package-manager)
|
- [Swift - Swift Package Manager](#swift---swift-package-manager)
|
||||||
- [Swift - Mint](#swift---mint)
|
- [Swift - Mint](#swift---mint)
|
||||||
|
- [* - ASDF](#---asdf)
|
||||||
- [* - Bazel](#---bazel)
|
- [* - Bazel](#---bazel)
|
||||||
|
|
||||||
## Bun
|
## Bun
|
||||||
@@ -49,7 +50,7 @@
|
|||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.bun/install/cache
|
~/.bun/install/cache
|
||||||
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
|
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
@@ -59,7 +60,7 @@
|
|||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~\.bun
|
~\.bun
|
||||||
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
|
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
|
||||||
```
|
```
|
||||||
|
|
||||||
## C# - NuGet
|
## C# - NuGet
|
||||||
@@ -681,6 +682,38 @@ steps:
|
|||||||
${{ runner.os }}-mint-
|
${{ runner.os }}-mint-
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## * - ASDF
|
||||||
|
|
||||||
|
[ASDF](https://asdf-vm.com), see [#235](https://github.com/asdf-vm/actions/issues/235):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Setup ASDF itself
|
||||||
|
uses: asdf-vm/actions/setup@v3
|
||||||
|
|
||||||
|
- name: Cache ASDF
|
||||||
|
uses: actions/cache@v4
|
||||||
|
id: asdf-cache
|
||||||
|
with:
|
||||||
|
# https://github.com/asdf-vm/asdf/blob/master/.gitignore
|
||||||
|
path: |
|
||||||
|
~/.asdf/installs
|
||||||
|
~/.asdf/plugins
|
||||||
|
~/.asdf/shims
|
||||||
|
key: ${{ runner.os }}-asdf-tools-${{ hashFiles('.tool-versions') }}
|
||||||
|
restore-keys: ${{ runner.os }}-asdf-tools-
|
||||||
|
|
||||||
|
- name: Install ASDF plugins
|
||||||
|
uses: asdf-vm/actions/install@v3
|
||||||
|
# See https://github.com/asdf-vm/actions/issues/445
|
||||||
|
if: ${{ steps.asdf-cache.outputs.cache-hit != 'true' }}
|
||||||
|
with:
|
||||||
|
asdf_branch: v0.14.0
|
||||||
|
|
||||||
|
- name: Reshim installed ASDF tools
|
||||||
|
shell: bash
|
||||||
|
run: asdf reshim
|
||||||
|
```
|
||||||
|
|
||||||
## * - Bazel
|
## * - Bazel
|
||||||
|
|
||||||
[`bazelisk`](https://github.com/bazelbuild/bazelisk) does not have be to separately downloaded and installed because it's already included in GitHub's `ubuntu-latest` and `macos-latest` base images.
|
[`bazelisk`](https://github.com/bazelbuild/bazelisk) does not have be to separately downloaded and installed because it's already included in GitHub's `ubuntu-latest` and `macos-latest` base images.
|
||||||
|
|||||||
Reference in New Issue
Block a user