Giter Site home page Giter Site logo

animmouse / setup-cloudflared Goto Github PK

View Code? Open in Web Editor NEW
21.0 5.0 5.0 28 KB

Setup/Install Cloudflare Tunnel client for GitHub Actions

Home Page: https://github.com/marketplace/actions/setup-cloudflared

License: Mozilla Public License 2.0

Shell 42.03% PowerShell 57.97%
cloudflare github-actions reverse-proxy cloudflare-tunnel actionshackathon21 tunnel proxy actions action cloudflared

setup-cloudflared's Introduction

Setup cloudflared for GitHub Actions

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 action will automatically sign in and start Cloudflare Tunnel.

This GitHub action participated on 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.)

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
    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.

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 }}
      
    - 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

If you don't want to autostart Cloudflare Tunnel, set autostart: to false.

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 }}
      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.

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.

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:

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

Similar actions

  1. vmactions/cf-tunnel
  2. apogiatzis/ngrok-tunneling-action
  3. vmactions/ngrok-tunnel
  4. debugci/setup-cloudflared

setup-cloudflared's People

Contributors

animmouse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

setup-cloudflared's Issues

Move away from Cloudflare Tunnel centric operation

The cloudflared daemon is not just about cloudflared tunnel anymore, we now have cloudflared access that allows GitHub Actions runner to access services behind Cloudflare, cloudflared service for tunnels configured via dashboard, and TryCloudflare that allows to use Cloudflare Tunnel without an account and domain name.

Moving away from Cloudflare Tunnel centric is the way forward, but this will break many workflows that depend on setup-cloudflared, so moving to v2 is required.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.