Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
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
95 changes: 95 additions & 0 deletions .github/workflows/ona-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Ona Preview Environment

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
add-ona-preview-link:
name: Add Ona Preview Link
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- name: Add Ona Preview Comment
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const repoOwner = context.repo.owner;
const repoName = context.repo.repo;
const branch = context.payload.pull_request.head.ref;
const headRepo = context.payload.pull_request.head.repo.full_name;

// Construct the Ona preview URL
// For Gitpod/Ona, the URL format is: https://gitpod.io/#<repository-url>
const gitpodUrl = `https://gitpod.io/#https://github.com/${headRepo}/tree/${branch}`;

// Alternative Ona URL format (if using ona.dev domain)
const onaUrl = `https://ona.dev/#https://github.com/${headRepo}/tree/${branch}`;

const comment = `## 🚀 Ona Preview Environment

This pull request can be previewed in a cloud development environment:

**Option 1: Using Gitpod (Ona)**
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](${gitpodUrl})

**Option 2: Using Ona**
[🌐 Open in Ona](${onaUrl})

**Direct URLs:**
- Gitpod: ${gitpodUrl}
- Ona: ${onaUrl}

### Getting Started

1. Click one of the buttons above to open this PR in a cloud development environment
2. Wait for the environment to build (first time may take ~10 minutes)
3. The Forem server will automatically start and open at port 3000
4. All dependencies (PostgreSQL, Redis, etc.) are pre-configured

### Notes

- The environment is fully configured with all necessary services
- Database will be seeded automatically on first run
- Changes you make in the preview environment are not persisted to this PR
- Use this for testing and reviewing changes before merging

---

*This preview environment is provided via Ona/Gitpod integration*`;

// Check if we already added a comment
const { data: comments } = await github.rest.issues.listComments({
owner: repoOwner,
repo: repoName,
issue_number: prNumber,
});

const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Ona Preview Environment')
);

if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: repoOwner,
repo: repoName,
comment_id: botComment.id,
body: comment
});
console.log('Updated existing Ona preview comment');
} else {
// Create new comment
await github.rest.issues.createComment({
owner: repoOwner,
repo: repoName,
issue_number: prNumber,
body: comment
});
console.log('Added new Ona preview comment');
}

6 changes: 3 additions & 3 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ github:
# enable for pull requests coming from forks (defaults to false)
pullRequestsFromForks: true
# add a "Review in Gitpod" button as a comment to pull requests (defaults to true)
addComment: false
addComment: true
# add a "Review in Gitpod" button to pull requests (defaults to false)
addBadge: false
addBadge: true
# add a label once the prebuild is ready to pull requests (defaults to false)
addLabel: false
addLabel: prebuilt-in-gitpod
# add a check to pull requests (defaults to true)
addCheck: true
71 changes: 71 additions & 0 deletions .ona.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Ona (formerly Gitpod) Configuration
# This configuration file sets up cloud development environments for Forem

# Uses the existing Dockerfile/Containerfile
image:
file: Dockerfile

ports:
- name: Rails Server
port: 3000
onOpen: notify
visibility: public
- name: Webpack Dev Server
port: 3035
onOpen: ignore
visibility: private
- name: PostgreSQL
port: 5432
onOpen: ignore
visibility: private
- name: Redis
port: 6379
onOpen: ignore
visibility: private

tasks:
- name: Setup Environment
before: |
# Create .env file if it doesn't exist
if [ ! -f .env ]; then
cp .env_sample .env
fi

# Configure for Ona environment
echo "APP_DOMAIN=\"$(gp url 3000 | cut -f 3 -d /)\"" >> .env
echo 'APP_PROTOCOL="https://"' >> .env
echo 'COMMUNITY_NAME="DEV(Ona Preview)"' >> .env

# Install required gems
gem install dip
gem install solargraph
init: |
# Provision the development environment
dip provision
command: |
# Start the Rails server and open preview
gp ports await 3000
printf "🚀 Forem development environment is ready!\n"
printf "Opening preview at $(gp url 3000)...\n"
gp preview $(gp url 3000)
dip up web

vscode:
extensions:
- Shopify.ruby-lsp
- KoichiSasada.vscode-rdbg
- dbaeumer.vscode-eslint
- esbenp.prettier-vscode
- eamodio.gitlens

github:
prebuilds:
master: true
branches: false
pullRequests: true
pullRequestsFromForks: true
addComment: true
addBadge: true
addLabel: prebuilt-in-ona
addCheck: true

15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,19 @@ transitioning to a [Preact](https://preactjs.com/)-first frontend.
A more complete overview of our stack is available in
[our docs](https://developers.forem.com/technical-overview/stack).

To **launch Forem in Gitpod**, navigate to
[https://gitpod.io/#https://github.com/{your_github_username}/forem](https://gitpod.io/#https://github.com/{your_github_username}/forem).
### Quick Start with Cloud Development Environments

To **launch Forem in Ona** (formerly Gitpod), the project is fully configured for Ona development environments. Simply open the project in Ona and the environment will be automatically configured with all necessary services and dependencies.
**Option 1: Launch in Gitpod**

Navigate to [https://gitpod.io/#https://github.com/{your_github_username}/forem](https://gitpod.io/#https://github.com/{your_github_username}/forem)

**Option 2: Launch in Ona** (formerly Gitpod)

Navigate to [https://ona.dev/#https://github.com/{your_github_username}/forem](https://ona.dev/#https://github.com/{your_github_username}/forem)

Both options provide fully configured development environments with all necessary services and dependencies pre-installed.

**🚀 PR Preview Environments**: When you open a pull request, an Ona preview environment is automatically prepared! Look for the preview link in the PR comments to test changes without local setup. See [Ona Preview Environments Guide](docs/ona_preview_environments.md) for details.

### Installation Documentation

Expand Down
Loading
Loading