Skip to content

Commit

Permalink
Setup actions
Browse files Browse the repository at this point in the history
  • Loading branch information
yescallop committed Nov 10, 2024
1 parent af7b7f0 commit ca57bb4
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/deploy-to-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy to Pages

on:
# Runs on pushes targeting the default branch
# push:
# branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Trunk
uses: jetli/[email protected]
- name: Build
run: trunk build --release --no-default-features
working-directory: client
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: client/dist
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 4 additions & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ web-sys = { version = "0.3.72", features = [
"TextMetrics",
] }

[features]
default = ["online"]
online = []

[lints]
workspace = true
5 changes: 4 additions & 1 deletion client/src/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ impl DialogImpl for MainMenuDialog {
<p class="title">"Main Menu"</p>
<div class="menu-btn-group">
<button>"Play Offline"</button>
<button value=ret!(Online)>"Play Online"</button>
{
#[cfg(feature = "online")]
view! { <button value=ret!(Online)>"Play Online"</button> }
}
</div>
}
}
Expand Down
21 changes: 11 additions & 10 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod game_view;
use base64::{prelude::BASE64_STANDARD, Engine};
use c6ol_core::{
game::{Move, Point, Record, Stone},
protocol::{ClientMessage, GameId, Request, ServerMessage},
protocol::{ClientMessage, Request, ServerMessage},
};
use dialog::*;
use leptos::{ev, prelude::*};
Expand Down Expand Up @@ -348,16 +348,17 @@ pub fn App() -> impl IntoView {
return;
}

if let Some(id) = GameId::try_from(id.as_bytes())
.ok()
.filter(|id| id.iter().all(u8::is_ascii_alphanumeric))
{
connect(ClientMessage::Join(id));
} else {
show_dialog(Dialog::from(ErrorDialog {
message: "Invalid game ID.".into(),
}));
#[cfg(feature = "online")]
if let Ok(id) = c6ol_core::protocol::GameId::try_from(id.as_bytes()) {
if id.iter().all(u8::is_ascii_alphanumeric) {
connect(ClientMessage::Join(id));
return;
}
}

show_dialog(Dialog::from(ErrorDialog {
message: "Invalid game ID.".into(),
}));
};

let on_event = move |ev: Event| match ev {
Expand Down

0 comments on commit ca57bb4

Please sign in to comment.