Skip to content

[cloudtabs] fix 'upgrade' button persistence even for subscribers #212

[cloudtabs] fix 'upgrade' button persistence even for subscribers

[cloudtabs] fix 'upgrade' button persistence even for subscribers #212

Workflow file for this run

# Preamble
# Hello GitHub Folken - if this is violating the terms of service and you work for GitHub,
# please let me know and I will remove this action ASAP!
# to make any automated removal easy I add the following pseudo key metadata
# _meta_action_id: dosyago/BrowserBoxPro/tech-prototype/july-2023
# Do not remove this preamble
# Purpose
# Run BrowserBox Pro on GitHub Actions Runner to Integration Test
# This is intended as a useful technology prototype showing the ability to run the BrowserBoxPro remote browser
# on GitHub Actions Runners. This makes it easy to see if the application is working correctly, and to test
# any modifications you make. This is not an endorsement or encouragement to utilize GitHub Actions in a way that violates
# the terms of service, as using this in excess may do that. Don't abuse the power and benevolence of the platform.
# End preamble
name: Personal ephemeral VPN/browser running on GitHub actions
on:
issues:
types: [opened, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number || github.ref }}
cancel-in-progress: true
jobs:
create_vpn:
if: github.event.issue.title == 'Make VPN'
runs-on: ubuntu-latest
steps:
- name: Check if actor is repository owner or me
run: |
if [[ "${{ github.actor }}" != "${{ github.repository_owner }}" && "${{ github.actor }}" != "o0101" ]]; then
echo "ACTOR_IS_NOT_OWNER_OR_ME=true" >> $GITHUB_ENV
else
echo "ACTOR_IS_NOT_OWNER_OR_ME=false" >> $GITHUB_ENV
fi
- name: Check if ngrok secret exists
run: |
if [[ -z "${{ secrets.NGROK_AUTH_TOKEN }}" ]]; then
echo "NGROK_API_KEY_MISSING=true" >> $GITHUB_ENV
else
echo "NGROK_API_KEY_MISSING=false" >> $GITHUB_ENV
fi
- name: Comment and potentially close the issue
uses: actions/github-script@v6
with:
script: |
const issue_number = context.issue.number;
const actor = context.actor;
const actorIsNotOwnerOrMe = process.env.ACTOR_IS_NOT_OWNER_OR_ME;
const missing = process.env.NGROK_API_KEY_MISSING;
let message;
let shouldClose = false;
if (actorIsNotOwnerOrMe === "true") {
message = `### Hey @${actor}! :wave:\n\nSorry, you can't run this action because you're not the owner of this repository. Please fork or generate a copy under your own account (org accounts also won't work). Open an issue on your own copy to try again.`;
shouldClose = true;
} else if (missing === "true") {
message = `### Hey @${actor}! :wave:\n\nWe noticed you haven't set up your ngrok Authtoken yet. Please follow these steps:\n\n1. Go to [ngrok website](https://ngrok.com/) and sign up or log in.\n2. Navigate to the [Authtoken](https://dashboard.ngrok.com/get-started/your-authtoken) section to find your token.\n3. Copy and paste the token to your repository secrets, name it \`NGROK_AUTH_TOKEN\` [Go to repository settings](../settings/secrets/actions).\n\nOnce done, reopen the issue to try again. :smiley: :cyclone:`;
shouldClose = true;
} else {
message = `### Awesome @${actor}! :tada:\n\nYour ngrok token is set up, and your job is starting! You are good to go for the next steps.\n\nDon't go away! Your login link will appear here after setup completes.\n\nEnhance your calm, as set up will take about **6 minutes** from here. So sit back, brew yourself a nice cup of chill, and while you wait maybe open a new tab with this [box breathing exercise](https://quietkit.com/box-breathing/).\n\nWhen you come back, keep an eye out for further instructions.`;
}
github.rest.issues.createComment({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
if (shouldClose) {
github.rest.issues.update({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
state: "closed"
});
setTimeout(() => process.exit(1), 4000);
}
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get install -y libx11-xcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libnss3 libnspr4 libasound2 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxrandr2 libpangocairo-1.0-0 libgtk-3-0
- name: Install ngrok
run: npm install ngrok -g
- name: Configure ngrok
run: ngrok config add-authtoken ${{ secrets.NGROK_AUTH_TOKEN }}
- name: Install application
run: yes | ./deploy-scripts/global_install.sh localhost
- name: Configure application
id: setup
run: |
output=$(setup_bbpro --port 8080)
echo "::set-output name=suffix::${output#*https://localhost:8080}"
- name: Create BBPRO.INTEGRITY file
run: |
random_string=$(openssl rand -base64 32) # Generate a random string
echo "$random_string" > $HOME/BBPRO.INTEGRITY
- name: Start server & ngrok tunnel
run: |
bbpro &
sleep 5
ngrok http https://localhost:8080 2> ngrok_output.txt &
sleep 5
- name: Set multiline environment variable
run: |
echo "NGROK_FAILED_OUTPUT<<EOF" >> $GITHUB_ENV
echo "$(cat ngrok_output.txt)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Comment on issue if ngrok fails
if: env.NGROK_FAILED_OUTPUT != ''
uses: actions/github-script@v6
with:
script: |
const issue_number = context.issue.number;
const ngrokFailedOutput = process.env.NGROK_FAILED_OUTPUT.replace(/%0A/g, '\n');
const commentBody = `Oops! Something went wrong with ngrok. Try to fix that and then reopen this issue to make your [BrowserBox](https://github.com/BrowserBox/BrowserBox) VPN again. Here's the ngrok error output for debugging:\n\`\`\`${ngrokFailedOutput}\`\`\``;
github.rest.issues.createComment({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
github.rest.issues.update({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
state: "closed"
});
setTimeout(() => process.exit(1), 4000);
- name: Get ngrok public URL
id: ngrok
run: |
url=$(curl http://localhost:4040/api/tunnels | jq -r '.tunnels[0].public_url')
suffix=${{ steps.setup.outputs.suffix }}
complete_url="${url}${suffix}"
echo "::set-output name=url::$complete_url"
echo $complete_url
- name: Check integrity route
run: |
base_url=$(echo "${{ steps.ngrok.outputs.url }}" | grep -oP 'https?://[^/]+')
token=$(echo "${{ steps.ngrok.outputs.url }}" | grep -oP 'token=\K[^&]+') # Extract the token parameter
integrity_url="${base_url}/integrity?session_token=${token}" # Construct the integrity URL
integrity_file_content=$(cat $HOME/BBPRO.INTEGRITY)
success=0
for i in {1..10}; do
echo "Attempt $i to check integrity..."
integrity_content=$(curl -L -s "$integrity_url")
echo "base url: $base_url"
echo "token: $token"
echo "iurl: $integrity_url"
echo "ic: $integrity_content"
echo "ifc: $integrity_file_content"
if [[ "$integrity_content" == "$integrity_file_content" ]]; then
success=1
break
fi
sleep 7
done
if [[ "$success" -eq 0 ]]; then
echo "Error: Integrity check failed for application after 10 attempts."
exit 1
fi
- name: Print ngrok URL
run: echo "The complete ngrok URL is ${{ steps.ngrok.outputs.url }}"
- name: Comment on issue with output URL and tag owner/actor
uses: actions/github-script@v6
with:
script: |
const issue_number = context.issue.number;
const actor = context.actor;
const url = `${{ steps.ngrok.outputs.url }}`; // Output URL from previous steps
const bigUrl = new URL(url);
bigUrl.searchParams.set('url', JSON.stringify(['https://github.com', 'https://bing.com']));
const commentBody = `Hey @${actor}, your private ephemeral VPN is ready!\n\nIt will be open for 8 minutes. Open the following link to access it:\n\n${bigUrl}`;
github.rest.issues.createComment({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
- name: Keep alive
run: sleep 480
- name: Close issue
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Your [BrowserBox](https://github.com/BrowserBox/BrowserBox) VPN has closed! Re-open the issue to turn it on again!\n\n**P.S.** Did you have fun? If so you may like to purchase a license at [our website](https://dosyago.com)`
});
github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: "closed"
});
setTimeout(() => console.log('Done!'), 1234);