Setup Cloudflare Tunnel client for GitHub Actions.
This action installs cloudflared for use in actions by installing it on tool cache using AnimMouse/tool-cache.
This GitHub action participated in the GitHub Actions Hackathon 2021, but sadly, it lost.
Test page for setup-cloudflared: https://setup-cloudflared.44444444.xyz (This will only work when the test action is running.)
To use cloudflared
, run this action before cloudflared
.
steps:
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v2
- name: Check cloudflared version
run: cloudflared -v
Use Cloudflare Tunnel to expose servers running inside GitHub Actions to the Internet.
- Encode the JSON credential in Base64 using this command
base64 -w 0 <cloudflare-tunnel-id>.json
and paste it toCLOUDFLARE_TUNNEL_CREDENTIAL
secret. - Inside the config.yaml, set
credentials-file:
to:- Ubuntu:
/home/runner/.cloudflared/<cloudflare-tunnel-id>.json
- Windows:
C:\Users\runneradmin\.cloudflared\<cloudflare-tunnel-id>.json
- macOS:
/Users/runner/.cloudflared/<cloudflare-tunnel-id>.json
- Ubuntu:
- Encode the config.yaml in Base64 using this command
base64 -w 0 config.yaml
and paste it toCLOUDFLARE_TUNNEL_CONFIGURATION
variable. - Add the Cloudflare Tunnel ID to
CLOUDFLARE_TUNNEL_ID
variable.
To gracefully shutdown Cloudflare Tunnel after being started in the background, use the AnimMouse/setup-cloudflared/shutdown
action as composite actions does not support post:
yet.
The Shutdown Cloudflare Tunnel
action should have if: '! cancelled()'
so that it will run even if the workflow fails.
steps:
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v2
- name: Setup cloudflared tunnel
uses: AnimMouse/setup-cloudflared/tunnel@v2
with:
cloudflare_tunnel_credential: ${{ secrets.CLOUDFLARE_TUNNEL_CREDENTIAL }}
cloudflare_tunnel_configuration: ${{ vars.CLOUDFLARE_TUNNEL_CONFIGURATION }}
cloudflare_tunnel_id: ${{ vars.CLOUDFLARE_TUNNEL_ID }}
- name: Start Python HTTP server
run: timeout 5m python -m http.server 8080 || true
- name: Shutdown and view logs of cloudflared
if: '! cancelled()'
uses: AnimMouse/setup-cloudflared/shutdown@v2
If you don't want to automatically start Cloudflare Tunnel in the background, set autostart:
to false
.
steps:
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v2
- name: Setup cloudflared tunnel
uses: AnimMouse/setup-cloudflared/tunnel@v2
with:
cloudflare_tunnel_credential: ${{ secrets.CLOUDFLARE_TUNNEL_CREDENTIAL }}
cloudflare_tunnel_configuration: ${{ vars.CLOUDFLARE_TUNNEL_CONFIGURATION }}
cloudflare_tunnel_id: ${{ vars.CLOUDFLARE_TUNNEL_ID }}
autostart: false
- name: Manually start cloudflared tunnel
run: timeout 5m cloudflared tunnel run || true
You can use Cloudflare Tunnel without a Cloudflare account and a domain name. Your quick tunnel URL will appear on the Actions log.
steps:
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v2
- name: Setup cloudflared tunnel
uses: AnimMouse/setup-cloudflared/tunnel@v2
with:
url: http://localhost:8080
- name: Start Python HTTP server
run: timeout 5m python -m http.server 8080 || true
- name: Shutdown and view logs of cloudflared
if: '! cancelled()'
uses: AnimMouse/setup-cloudflared/shutdown@v2
You can specify the version you want. By default, this action downloads the latest version if the version is not specified.
steps:
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v2
with:
version: 2024.2.1
This action automatically uses a GitHub token in order to authenticate with the GitHub API and avoid rate limiting. You can also specify your own read-only fine-grained personal access token.
steps:
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v2
with:
token: ${{ secrets.GH_PAT }}
Ubuntu:
url: http://localhost:8080
tunnel: deadbeef-1234-4321-abcd-123456789abc
credentials-file: /home/runner/.cloudflared/deadbeef-1234-4321-abcd-123456789abc.json
Windows:
url: http://localhost:8080
tunnel: deadbeef-1234-4321-abcd-123456789abc
credentials-file: C:\Users\runneradmin\.cloudflared\deadbeef-1234-4321-abcd-123456789abc.json
macOS:
url: http://localhost:8080
tunnel: deadbeef-1234-4321-abcd-123456789abc
credentials-file: /Users/runner/.cloudflared/deadbeef-1234-4321-abcd-123456789abc.json