Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idea #2

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
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
14 changes: 14 additions & 0 deletions .github/workflows/publish-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: publish-action
on:
release:
types: released
concurrency: ${{ github.workflow }}
jobs:
publish-action:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
source-tag: ${{ github.event.release.tag_name }}
35 changes: 35 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test action
on:
push:
branches: "main"
paths-ignore:
- .gitignore
- README.md
- LICENSE
- .github/**
- "!.github/workflows/test-action.yml"
- start/**
- stop/**
pull_request:
paths-ignore:
- .gitignore
- README.md
- LICENSE
- .github/**
- "!.github/workflows/test-action.yml"
- start/**
- stop/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-action:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./
- run: cloudflared --version
37 changes: 37 additions & 0 deletions .github/workflows/test-start-stop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test start & stop
on:
push:
branches: "main"
paths-ignore:
- .gitignore
- README.md
- LICENSE
- .github/**
- "!.github/workflows/test-start-stop.yml"
pull_request:
paths-ignore:
- .gitignore
- README.md
- LICENSE
- .github/**
- "!.github/workflows/test-start-stop.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-start-stop:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./
- uses: ./start
with:
run: npx -y serve
url: http://localhost:3000
- shell: bash
run: sleep 100
- uses: ./stop
87 changes: 0 additions & 87 deletions .github/workflows/test.yaml

This file was deleted.

73 changes: 69 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,61 @@
# Setup Cloudflare Tunnel client

🚛 Installs `cloudflared` for GitHub Actions

<div align="center">

![](https://i.imgur.com/fCYSI7n.png)

</div>

📦 Downloads & installs the `cloudflared` binary \
🚀 Zero-config to get started; supports [`config.yml`](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-local-tunnel/#4-create-a-configuration-file) for advanced use \
▶️ Includes start & stop sub-actions for [Cloudflare Quick Tunnels](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/do-more-with-tunnels/trycloudflare/) \
🌈 Works on Windows, macOS, and Linux runners

## Usage

![GitHub Actions](https://img.shields.io/static/v1?style=for-the-badge&message=GitHub+Actions&color=2088FF&logo=GitHub+Actions&logoColor=FFFFFF&label=)
![GitHub](https://img.shields.io/static/v1?style=for-the-badge&message=GitHub&color=181717&logo=GitHub&logoColor=FFFFFF&label=)

**🚀 Here's what you want:**

```yml
on: push
jobs:
job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: AnimMouse/setup-cloudflared@v2
- uses: AnimMouse/setup-cloudflared/start@v2
with:
run: npx -y serve
url: http://localhost:3000
- run: sleep 100
- uses: AnimMouse/setup-cloudflared/stop@v2 # OPTIONAL
```

[📚 Read more about Cloudflare Tunnels and the Cloudflare Tunnel Client](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/)

### Options

There's only one option so far. If you want to see automatic login or similar,
just open an Issue! ❤️

- **`cloudflared-version`:** Specifies which version of cloudflared to install from the GitHub Releases page. Note that cloudflared uses a date-based versioning scheme. The default value for this field is `latest` which will automagically default to the latest GitHub Release. This field does support semver ranges like `^2023.0.0`.

- **`cloudflared-token`:** The GitHub token to use when fetching the version list from [cloudflare/cloudflared](https://github.com/cloudflare/cloudflared/releases). You shouldn't have to touch this. The default is the `github.token` if you're on github.com or unauthenticated (rate limited) if you're not on github.com.

## Development

![Bash](https://img.shields.io/static/v1?style=for-the-badge&message=Bash&color=4EAA25&logo=GNU+Bash&logoColor=FFFFFF&label=)
![PowerShell](https://img.shields.io/static/v1?style=for-the-badge&message=PowerShell&color=5391FE&logo=PowerShell&logoColor=FFFFFF&label=)

This GitHub action is build using Bash.

# Setup cloudflared for GitHub Actions

Setup [Cloudflare Tunnel client](https://github.com/cloudflare/cloudflared) for GitHub Actions.

This action installs [cloudflared](https://github.com/cloudflare/cloudflared) for use in actions by installing it on tool cache using [AnimMouse/tool-cache](https://github.com/AnimMouse/tool-cache).
Expand All @@ -10,6 +67,7 @@ This GitHub action participated on [GitHub Actions Hackathon 2021](https://dev.t
Test page for setup-cloudflared: https://setup-cloudflared.44444444.xyz (This will only work when the test action is running.)

## Usage

1. Encode the JSON credential in Base64 using this command `base64 -w 0 <cloudflare-tunnel-id>.json` and paste it to `CLOUDFLARE_TUNNEL_CREDENTIAL` secret.
2. At the config.yaml, set `credentials-file:` to:
1. Ubuntu: `/home/runner/.cloudflared/<cloudflare-tunnel-id>.json`
Expand All @@ -29,10 +87,10 @@ steps:
cloudflare_tunnel_credential: ${{ secrets.CLOUDFLARE_TUNNEL_CREDENTIAL }}
cloudflare_tunnel_configuration: ${{ secrets.CLOUDFLARE_TUNNEL_CONFIGURATION }}
cloudflare_tunnel_id: ${{ secrets.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: always()
uses: AnimMouse/setup-cloudflared/shutdown@v1
Expand All @@ -49,12 +107,13 @@ steps:
cloudflare_tunnel_configuration: ${{ secrets.CLOUDFLARE_TUNNEL_CONFIGURATION }}
cloudflare_tunnel_id: ${{ secrets.CLOUDFLARE_TUNNEL_ID }}
autostart: false

- name: Manually start cloudflared
run: timeout 5m cloudflared tunnel run || true
```

### Specific version

You can specify the version you want. By default, this action downloads the latest version if version is not specified.

```yaml
Expand All @@ -69,6 +128,7 @@ steps:
```

### GitHub token

This action automatically uses a GitHub token in order to authenticate with GitHub API and avoid rate limiting. You can also specify your own read-only fine-grained personal access token.

```yaml
Expand All @@ -83,29 +143,34 @@ steps:
```

### Example config.yaml file

Ubuntu:

```yaml
url: http://localhost:8080
tunnel: deadbeef-1234-4321-abcd-123456789abc
credentials-file: /home/runner/.cloudflared/deadbeef-1234-4321-abcd-123456789abc.json
```

Windows:

```yaml
url: http://localhost:8080
tunnel: deadbeef-1234-4321-abcd-123456789abc
credentials-file: C:\Users\runneradmin\.cloudflared\deadbeef-1234-4321-abcd-123456789abc.json
```

macOS:

```yaml
url: http://localhost:8080
tunnel: deadbeef-1234-4321-abcd-123456789abc
credentials-file: /Users/runner/.cloudflared/deadbeef-1234-4321-abcd-123456789abc.json
```

### Similar actions

1. [vmactions/cf-tunnel](https://github.com/vmactions/cf-tunnel)
2. [apogiatzis/ngrok-tunneling-action](https://github.com/apogiatzis/ngrok-tunneling-action)
3. [vmactions/ngrok-tunnel](https://github.com/vmactions/ngrok-tunnel)
4. [debugci/setup-cloudflared](https://github.com/debugci/setup-cloudflared)
4. [debugci/setup-cloudflared](https://github.com/debugci/setup-cloudflared)
Loading