Skip to content

Commit

Permalink
docs: Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AnimMouse committed Aug 31, 2023
1 parent f3ec28d commit 625fcfc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 12 deletions.
67 changes: 57 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@ This action installs [cloudflared](https://github.com/cloudflare/cloudflared) fo

This action will automatically sign in and start Cloudflare Tunnel.

Other virtual environments besides Ubuntu are not supported yet.
This GitHub action participated on [GitHub Actions Hackathon 2021](https://dev.to/animmouse/expose-your-web-server-on-github-actions-to-the-internet-using-cloudflare-tunnel-ego), but sadly, it lost.

[Test page for setup-cloudflared](https://setup-cloudflared.0000004.xyz) (This will only work when the test action is running.)
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 `/home/runner/.cloudflared/<cloudflare-tunnel-id>.json`
3. Encode the config.yaml in base64 using this command `base64 -w 0 config.yaml` and paste it to `CLOUDFLARE_TUNNEL_CONFIGURATION` secret.
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`
2. Windows: `C:\Users\runneradmin\.cloudflared\<cloudflare-tunnel-id>.json`
3. macOS: `/Users/runner/.cloudflared/<cloudflare-tunnel-id>.json`
3. Encode the config.yaml in Base64 using this command `base64 -w 0 config.yaml` and paste it to `CLOUDFLARE_TUNNEL_CONFIGURATION` secret.
4. Add the Cloudflare Tunnel ID to `CLOUDFLARE_TUNNEL_ID` secret.

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: always()` so that it will run even if the workflow failed or canceled.

```yaml
steps:
- name: Setup Cloudflare Tunnel
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v1
with:
cloudflare_tunnel_credential: ${{ secrets.CLOUDFLARE_TUNNEL_CREDENTIAL }}
Expand All @@ -30,7 +33,7 @@ steps:
- name: Start Python HTTP server
run: timeout 5m python -m http.server 8080 || true

- name: Shutdown and view logs of Cloudflare Tunnel
- name: Shutdown and view logs of cloudflared
if: always()
uses: AnimMouse/setup-cloudflared/shutdown@v1
```
Expand All @@ -39,26 +42,70 @@ If you don't want to autostart Cloudflare Tunnel, set `autostart:` to `false`.

```yaml
steps:
- name: Setup Cloudflare Tunnel
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v1
with:
cloudflare_tunnel_credential: ${{ secrets.CLOUDFLARE_TUNNEL_CREDENTIAL }}
cloudflare_tunnel_configuration: ${{ secrets.CLOUDFLARE_TUNNEL_CONFIGURATION }}
cloudflare_tunnel_id: ${{ secrets.CLOUDFLARE_TUNNEL_ID }}
autostart: false

- name: Manually start Cloudflare Tunnel
- 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
steps:
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v1
with:
cloudflare_tunnel_credential: ${{ secrets.CLOUDFLARE_TUNNEL_CREDENTIAL }}
cloudflare_tunnel_configuration: ${{ secrets.CLOUDFLARE_TUNNEL_CONFIGURATION }}
cloudflare_tunnel_id: ${{ secrets.CLOUDFLARE_TUNNEL_ID }}
version: 2023.8.1
```

### 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
steps:
- name: Setup cloudflared
uses: AnimMouse/setup-cloudflared@v1
with:
cloudflare_tunnel_credential: ${{ secrets.CLOUDFLARE_TUNNEL_CREDENTIAL }}
cloudflare_tunnel_configuration: ${{ secrets.CLOUDFLARE_TUNNEL_CONFIGURATION }}
cloudflare_tunnel_id: ${{ secrets.CLOUDFLARE_TUNNEL_ID }}
token: ${{ secrets.GH_PAT }}
```

### 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)
3. [vmactions/ngrok-tunnel](https://github.com/vmactions/ngrok-tunnel)
4. [debugci/setup-cloudflared](https://github.com/debugci/setup-cloudflared)
3 changes: 1 addition & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ inputs:
description: Cloudflare Tunnel ID (deadbeef-1234-4321-abcd-123456789abc)
required: true
autostart:
description: Autostart Cloudflare Tunnel in the background
required: false
description: Autostart cloudflared in the background
default: true
version:
description: cloudflared version
Expand Down

0 comments on commit 625fcfc

Please sign in to comment.