Skip to content

Instantly share code, notes, and snippets.

@Corecii
Last active August 20, 2023 00:58
Show Gist options
  • Save Corecii/9439ee3ba9b322d53a438e6fb103fb38 to your computer and use it in GitHub Desktop.
Save Corecii/9439ee3ba9b322d53a438e6fb103fb38 to your computer and use it in GitHub Desktop.
Sample GitHub Actions file for running Roblox tests while connected to a WireGuard server

Sample Roblox Tests with WireGuard GitHub Actions File

Roblox changed their login behavior such that login cookies are tied to IP address. This prevents Roblox from working will with GitHub actions, as GitHub actions runners don't always use the same IP.

This action file connects to a WireGuard server first such that the action runner's IP appears to be the WireGuard server's. You can connect to the WireGuard server yourself to generate a login cookie so that the login IP is consistent between the original login and the action runners.

Server Setup

Servers capable of running WireGuard are easily found for $5 or so per month.

I personally prefer to install most services using Docker as it simplifies setup.

For me, this looks like:

  1. Find a VPS service capable of running WireGuard for around $5 or less. You will need IPv4 support with a static IP. Some popular options:
    • Digital Ocean has $5 VPS
    • Linode has $5 VPS
    • Vultr has $2.50 VPS in New Jersey, plus a reserved IPv4 makes this $5.50 per month.
    • Google, Amazon, and Microsoft should have their own hosted VM offerings. The weakest tiers usually come out to around $5 per month.
  2. Install your OS of choice. I typically use Ubuntu Server since I'm familiar with it.
  3. I connect VS Code to the server using its Remote SSH capabilities. This makes it easy to edit and view files on the server.
  4. Install Docker. Here is a guide I found from a Google search
  5. Install Docker Compose. Here is the next step from the above guide.
  6. Set up WireGuard
    • I used docker-wireguard

    • I used the sample docker-compose.yml file from the readme, with some changes.

      My changes
      • I put this at ~/wireguard-server/docker-compose.yml
      • I added a ~/wireguard-server/config directory for it to store its configuration.
      ---
      version: "2.1"
      services:
        wireguard:
          image: lscr.io/linuxserver/wireguard
          container_name: wireguard
          cap_add:
            - NET_ADMIN
            - SYS_MODULE
          environment:
            - PUID=1000
            - PGID=1000
            - TZ=Europe/London
            - SERVERURL=auto
            - SERVERPORT=51820
            # Each client should use a different peer file. We'll use `setup` to log in to Roblox, then we have 9 actions clients available!
            - PEERS=setup,actions_1,actions_2,actions_3,actions_4,actions_5,actions_6,actions_7,actions_8,actions_9
            - PEERDNS=auto
            - INTERNAL_SUBNET=10.13.13.0
            - ALLOWEDIPS=0.0.0.0/0
            - LOG_CONFS=true # you can flip this to false if you're going to download the files from the config folder
          volumes:
            - ./config:/config
            - /lib/modules:/lib/modules
          ports:
            - 51820:51820/udp
          sysctls:
            - net.ipv4.conf.all.src_valid_mark=1
          restart: unless-stopped
    • run WireGuard docker-compose up

    • If everything worked, stop WireGuard with Ctrl+C, then run it again in the background with docker-compose up -d

  7. Download your WireGuard config files.
    If you used the above container, these will be present under the config folder you specified.
  8. Connect to your WireGuard server from your computer to get a Roblox cookie tied to the WireGuard server's IP. Add the cookie to your GitHub repository as a secret ROBLOX_COOKIE
    WireGuard for Windows can be found here.
  9. Set the WIREGUARD_CONFIG secret to the contents of peer_actions_1.conf (or any WireGuard config file)
  10. Include this test.yml in your .github/workflows directory. Make any modifications you need to to the run-in-roblox command.
  11. Push! Your action should successfully connect to the WireGuard server, install Roblox, and run the script you specify in-game.
name: test
on: [push, pull_request]
jobs:
test:
runs-on: windows-latest
steps:
- name: Check out Repository
uses: actions/checkout@v2
- name: Download WireGuard
run: Invoke-WebRequest -Uri https://download.wireguard.com/windows-client/wireguard-installer.exe -OutFile ./wireguard-installer.exe;
- name: Install WireGuard
run: ./wireguard-installer.exe
- name: Store WireGuard Configuration
env:
WIREGUARD_CONFIG: ${{ secrets.WIREGUARD_CONFIG }}
run: $Env:WIREGUARD_CONFIG | Out-File -FilePath ./wireguard.conf
- name: Run WireGuard
run: "& \"c:\\Program Files\\WireGuard\\wireguard.exe\" /installtunnelservice .\\wireguard.conf"
- name: Install Roblox
uses: OrbitalOwen/roblox-win-installer-action@1.1
with:
cookie: ${{ secrets.ROBLOX_COOKIE }}
token: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 5
- name: Install Foreman
uses: Roblox/setup-foreman@v1
with:
version: "^1.0.0"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Pull Packages
run: wally install
- name: Build Place File
run: rojo build -o test.rbxlx rojo-test.project.json
- name: Run Tests
run: |
run-in-roblox --place test.rbxlx --script src/test/run-in-roblox.lua
| Tee-Object -file test-output.txt;
if($(Get-Content -Path test-output.txt -Tail 1) -match '0 failed'){ exit 0 } else { exit 1 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment