diff --git a/.github/actions/build-static/action.yaml b/.github/actions/build-static/action.yaml new file mode 100644 index 0000000..b3ae9aa --- /dev/null +++ b/.github/actions/build-static/action.yaml @@ -0,0 +1,25 @@ +name: Build Static Site +description: Build the Tokyo Rust static website +runs: + using: composite + steps: + - name: Install Zola + id: install-zola + uses: taiki-e/install-action@v2 + with: + tool: zola@0.17.2 + + - name: Setup Node + id: setup-node + uses: actions/setup-node@v4 + + - name: Install Node Packages + id: install-node-packages + shell: bash + run: cd static-site && npm install + + - name: Build Static Site + id: build-static-site + shell: bash + working-directory: ./static-site + run: zola build diff --git a/.github/actions/check-links/action.yaml b/.github/actions/check-links/action.yaml new file mode 100644 index 0000000..b3b433a --- /dev/null +++ b/.github/actions/check-links/action.yaml @@ -0,0 +1,12 @@ +name: Test Static Site Links +description: Test a built static site locally (not the deployed version) +runs: + using: composite + steps: + - name: Check Links + id: lychee + uses: lycheeverse/lychee-action@v1 + with: + args: --accept 200,429 --base ./static-site/public ./static-site/public + jobSummary: true + fail: true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..61bdcac --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,26 @@ +name: Build Site and Test Links +on: + workflow_dispatch: + pull_request: + branches: + - main + paths: + - static-site/** + +jobs: + deploy: + name: Build and Test Links + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v4 + id: checkout + + - name: Build The Site + id: build + uses: "./.github/actions/build-static" + + - name: Check Links + id: lychee + uses: "./.github/actions/check-links" diff --git a/.github/workflows/publish_static.yaml b/.github/workflows/publish_static.yaml index f3fa679..ed5a121 100644 --- a/.github/workflows/publish_static.yaml +++ b/.github/workflows/publish_static.yaml @@ -17,32 +17,13 @@ jobs: uses: actions/checkout@v4 id: checkout - - name: Install Zola - id: install-zola - uses: taiki-e/install-action@v2 - with: - tool: zola@0.17.2 - - - name: Setup Node - id: setup-node - uses: actions/setup-node@v4 - - - name: Install Node Packages - id: install-node-packages - run: cd static-site && npm install - - - name: Build Static Site - id: build-static-site - working-directory: ./static-site - run: zola build + - name: Build The Site + id: build + uses: "./.github/actions/build-static" - name: Check Links id: lychee - uses: lycheeverse/lychee-action@v1 - with: - args: --base ./static-site/public ./static-site/public - jobSummary: true - fail: true + uses: "./.github/actions/check-links" - name: Configure AWS Credentials id: configure-aws-creds diff --git a/infrastructure/static-site.tf b/infrastructure/static-site.tf index 4599b88..f53a077 100644 --- a/infrastructure/static-site.tf +++ b/infrastructure/static-site.tf @@ -6,7 +6,7 @@ locals { domain_name = "www.${local.host_name}" } -resource "aws_s3_bucket" "tokyo-rust" { +resource "aws_s3_bucket" "www_tokyorust" { bucket = local.domain_name tags = { @@ -15,12 +15,24 @@ resource "aws_s3_bucket" "tokyo-rust" { } } -resource "aws_s3_bucket_policy" "cloudfront_access_policy" { - bucket = aws_s3_bucket.tokyo-rust.id - policy = data.aws_iam_policy_document.allow_cloudfront_read_access.json +resource "aws_s3_bucket" "root_tokyorust" { + bucket = local.host_name + + tags = { + tokyorust = "" + static = "" + } +} + + resource "aws_s3_bucket_website_configuration" "root_tokyorust" { + bucket = aws_s3_bucket.root_tokyorust.id + + redirect_all_requests_to { + host_name = "${local.domain_name}" + } } -data "aws_iam_policy_document" "allow_cloudfront_read_access" { +data "aws_iam_policy_document" "www_tokyorust_allow_cloudfront_read_access" { version = "2012-10-17" statement { actions = [ @@ -36,19 +48,58 @@ data "aws_iam_policy_document" "allow_cloudfront_read_access" { effect = "Allow" resources = [ - aws_s3_bucket.tokyo-rust.arn, - "${aws_s3_bucket.tokyo-rust.arn}/*", + aws_s3_bucket.www_tokyorust.arn, + "${aws_s3_bucket.www_tokyorust.arn}/*", ] condition { test = "StringEquals" variable = "aws:SourceArn" - values = [aws_cloudfront_distribution.s3_distribution.arn] + values = [aws_cloudfront_distribution.www_distribution.arn] } } } +data "aws_iam_policy_document" "root_tokyorust_allow_cloudfront_read_access" { + version = "2012-10-17" + statement { + actions = [ + "s3:GetObject", + "s3:ListBucket", + ] + + principals { + type = "Service" + identifiers = ["cloudfront.amazonaws.com"] + } + + effect = "Allow" + + resources = [ + aws_s3_bucket.root_tokyorust.arn, + "${aws_s3_bucket.root_tokyorust.arn}/*", + ] + + condition { + test = "StringEquals" + variable = "aws:SourceArn" + values = [aws_cloudfront_distribution.root_distribution.arn] + } + + } +} + +resource "aws_s3_bucket_policy" "www_tokyorust_cloudfront_access_policy" { + bucket = aws_s3_bucket.www_tokyorust.id + policy = data.aws_iam_policy_document.www_tokyorust_allow_cloudfront_read_access.json +} + +resource "aws_s3_bucket_policy" "root_tokyorust_cloudfront_access_policy" { + bucket = aws_s3_bucket.root_tokyorust.id + policy = data.aws_iam_policy_document.root_tokyorust_allow_cloudfront_read_access.json +} + resource "aws_cloudfront_origin_access_control" "tokyorust" { name = "Tokyo-Rust-Access" description = "The access control for the Tokyo Rust website." @@ -61,9 +112,9 @@ resource "aws_cloudfront_origin_access_identity" "tokyorust" { comment = "Access identity for Tokyo Rust static site" } -resource "aws_cloudfront_distribution" "s3_distribution" { +resource "aws_cloudfront_distribution" "www_distribution" { origin { - domain_name = aws_s3_bucket.tokyo-rust.bucket_domain_name + domain_name = aws_s3_bucket.www_tokyorust.bucket_domain_name origin_id = local.s3_origin_id origin_access_control_id = aws_cloudfront_origin_access_control.tokyorust.id @@ -86,6 +137,7 @@ resource "aws_cloudfront_distribution" "s3_distribution" { } enabled = true + comment = "CloudFront distribution for ${local.domain_name}" default_root_object = "index.html" http_version = "http2" is_ipv6_enabled = true @@ -104,7 +156,62 @@ resource "aws_cloudfront_distribution" "s3_distribution" { default_ttl = 86400 max_ttl = 31536000 cache_policy_id = aws_cloudfront_cache_policy.tokyorust.id + } + + price_class = "PriceClass_200" + + tags = { + tokyorust = "" + static = "" } +} + +resource "aws_cloudfront_distribution" "root_distribution" { + origin { + domain_name = aws_s3_bucket_website_configuration.root_tokyorust.website_endpoint + origin_id = local.s3_origin_id + + custom_origin_config { + origin_protocol_policy = "http-only" + http_port = "80" + https_port = "443" + origin_ssl_protocols = ["TLSv1.2"] + } + + # s3_origin_config { + # origin_access_identity = aws_cloudfront_origin_access_identity.tokyorust.cloudfront_access_identity_path + # } + } + + aliases = [local.host_name] + + restrictions { + geo_restriction { + restriction_type = "none" + } + } + + viewer_certificate { + acm_certificate_arn = local.ssl_cert_arn + ssl_support_method = "sni-only" + } + + enabled = true + comment = "CloudFront distribution for ${local.host_name}" + default_root_object = "index.html" + http_version = "http2" + is_ipv6_enabled = true + + default_cache_behavior { + compress = true + viewer_protocol_policy = "redirect-to-https" + cached_methods = ["GET", "HEAD"] + target_origin_id = local.s3_origin_id + allowed_methods = ["GET", "HEAD"] + default_ttl = 86400 + max_ttl = 31536000 + cache_policy_id = aws_cloudfront_cache_policy.tokyorust.id + } price_class = "PriceClass_200" @@ -115,7 +222,7 @@ resource "aws_cloudfront_distribution" "s3_distribution" { } resource "aws_cloudfront_cache_policy" "tokyorust" { - name = "tokyo-tust-static-site-cache-policy" + name = "tokyo-rust-static-site-cache-policy" parameters_in_cache_key_and_forwarded_to_origin { cookies_config { @@ -140,50 +247,26 @@ resource "aws_route53_zone" "tokyorust" { } } -resource "aws_route53_record" "tokyorust" { +resource "aws_route53_record" "www_tokyorust" { zone_id = aws_route53_zone.tokyorust.id name = local.domain_name type = "A" alias { - name = aws_cloudfront_distribution.s3_distribution.domain_name - zone_id = aws_cloudfront_distribution.s3_distribution.hosted_zone_id + name = aws_cloudfront_distribution.www_distribution.domain_name + zone_id = aws_cloudfront_distribution.www_distribution.hosted_zone_id evaluate_target_health = false } } -resource "aws_iam_policy" "tokyorust-static-deployer" { - name = "tokyo-rust-static-deployer" - description = "Necessary permissions to deploy the Tokyo Rust static site" - - policy = jsonencode({ - Version = "2012-10-17", - Statement = [ - { - Sid = "AccessToWebsiteBuckets", - Effect = "Allow", - Action = [ - "s3:PutBucketWebsite", - "s3:PutObject", - "s3:PutObjectAcl", - "s3:GetObject", - "s3:ListBucket", - "s3:DeleteObject" - ], - Resource = [ - "${aws_s3_bucket.tokyo-rust.arn}", - "${aws_s3_bucket.tokyo-rust.arn}/*", - ] - }, - { - Sid = "AccessToCloudfront", - Effect = "Allow", - Action = [ - "cloudfront:GetInvalidation", - "cloudfront:CreateInvalidation"], - Resource = "*" - } - ] - }) +resource "aws_route53_record" "root_tokyorust" { + zone_id = aws_route53_zone.tokyorust.id + name = local.host_name + type = "A" + alias { + name = aws_cloudfront_distribution.root_distribution.domain_name + zone_id = aws_cloudfront_distribution.root_distribution.hosted_zone_id + evaluate_target_health = false + } } resource "aws_iam_user" "tokyorust-static-deployer" { @@ -196,13 +279,8 @@ resource "aws_iam_user" "tokyorust-static-deployer" { } } -resource "aws_iam_user_policy_attachment" "tokyorust-static-deployer" { - user = aws_iam_user.tokyorust-static-deployer.name - policy_arn = aws_iam_policy.tokyorust-static-deployer.arn -} - resource "aws_s3_bucket_website_configuration" "tokyorust" { - bucket = aws_s3_bucket.tokyo-rust.id + bucket = aws_s3_bucket.www_tokyorust.id index_document { suffix = "index.html" diff --git a/static-site/config.toml b/static-site/config.toml index 52f43a2..0f5defd 100644 --- a/static-site/config.toml +++ b/static-site/config.toml @@ -1,57 +1,62 @@ -# The URL the site will be built for base_url = "https://www.tokyorust.org" - -# Whether to automatically compile all Sass files in the sass directory compile_sass = true - -# Whether to build a search index to be used later on by a JavaScript library build_search_index = true - default_language = "en" +title = "Tokyo Rust" +description = """ +We are an English-speaking community of Rust users and enthusiasts. +Rustaceans of all skill levels are welcome to join our ranks! +""" [markdown] -# Whether to do syntax highlighting -# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola highlight_code = true -[extra] -# Put all your custom variables here -events_page_link = "https://www.meetup.com/tokyo-rust-meetup/" - -# about_us = """\ -# We are a voluntary organization (任意団体) based in Tokyo, Japan. \ -# Our mission is to maintain and grow an English-speaking community of Rust users and enthusiasts. \ -# We do our best to accommodate Japanese speakers, although our default language is English. \ -# Rustaceans of all skill levels are welcome to join our ranks! \ -# """ -[extra.jp] -about_us = """\ -私たちは、日本の東京に拠点を置く任意団体です。 \ -私たちの使命は、Rust ユーザーと愛好家の英語圏コミュニティを維持し、成長させることです。 \ -デフォルト言語は英語ですが、日本語話者に対応できるよう最善を尽くします。 \ +[translations] +[languages.jp] +title = "東京Rust" +description = """ +私たちは、Rust ユーザーと愛好家が集まる英語を話すコミュニティです。 あらゆるスキルレベルのRustaceanが私たちのランクに加わることを歓迎します! """ -join_next_event = "Join our next event!" - -[[extra.jp.card]] -title = "titleeeeeeeeee" -content = "content" -[extra.en] -about_us = """\ - a community of people who share your interest in the Rust programming language! -""" -join_next_event = "Join our next event!" -cards_header = "Monthly Presentations" - -[[extra.en.card]] -title = "Expand Your Knowledge" -content = "Learn more about the language itself, programming practices, and projects." - -[[extra.en.card]] -title = "Meet Likeminded People" -content = "Socialize other Rust enthusiasts and developers, share ideas, and make friends." - -[[extra.en.card]] -title = "Free Food and Drinks" -content = "Each event includes free pizza and beer." +[extra] +events_page_link = "https://guild.host/tokyo-rust/events/upcoming/" +donate_link = "https://donate.stripe.com/test_14k1731CJ4GK4YodQQ" +tokyo_rust_icon = "/tokyo-rust-outline-opt.svg" + +[[extra.socials]] +name = "meetup" +icon = "/meetup.svg" +url = "https://www.meetup.com/tokyo-rust-meetup/" + +[[extra.socials]] +name = "youtube" +icon = "/youtube.svg" +url = "https://www.youtube.com/@tokyo-rust-org" + +[[extra.socials]] +name = "guildhost" +icon = "/guild-host.png" +url = "https://guild.host/tokyo-rust" + +[[extra.socials]] +name = "github" +icon = "/github-icon.png" +url = "https://github.com/tokyo-rust" + +[[extra.socials]] +name = "linkedin" +icon = "/linkedin-icon.png" +url = "https://www.linkedin.com/company/99059952" + +[extra.translations.en] +home = "Home" +events = "Events" +donate = "Donate" +commercial_disclosure = "Commercial Disclosure" + +[extra.translations.jp] +home = "ホーム" +events = "イベント" +donate = "寄付" +commercial_disclosure = "特定商取引法に基づく表記" diff --git a/static-site/content/_index.jp.md b/static-site/content/_index.jp.md index 97d4941..da1aed1 100644 --- a/static-site/content/_index.jp.md +++ b/static-site/content/_index.jp.md @@ -1,21 +1,22 @@ +++ -title = "東京ラスト" +title = "東京Rust" [extra] -# about_us = """\ -# Join a community of people who share your interest in the Rust programming language! -# """ -# extra.jp.join_next_event = "Join oussssssssssssssr next event!" +about_us = """\ +Rust プログラミング言語への興味を共有する人々のコミュニティです。 +""" +join_next_event = "次のイベントにご参!" +cards_header = "月例プレゼンテーション" -# [[extra.landing_cards]] -# title = "aa" -# content = "aa" +[[extra.card]] +title = "知識を広げる" +content = "言語自体、プログラミングの実践、プロジェクトについて詳しく学びます。" -# [[extra.landing_cards]] -# title = "" -# content = "" +[[extra.card]] +title = "同じ志を持つ人々と出会う" +content = "他の Rust 愛好家や開発者と交流し、アイデアを共有し、友達を作りましょう。" -# [[extra.landing_cards]] -# title = "" -# content = "" +[[extra.card]] +title = "無料の食べ物と飲み物" +content = "各イベントには無料のピザとビールが含まれます。" +++ \ No newline at end of file diff --git a/static-site/content/_index.md b/static-site/content/_index.md index c539129..ea2ed48 100644 --- a/static-site/content/_index.md +++ b/static-site/content/_index.md @@ -2,19 +2,21 @@ title = "Tokyo Rust" [extra] +about_us = """\ +A community of people who share your interest in the Rust programming language! +""" +join_next_event = "Join our next event!" +cards_header = "Monthly Presentations" +[[extra.card]] +title = "Expand Your Knowledge" +content = "Learn more about the language itself, programming practices, and projects." -# [[extra.landing_cards]] -# title = "aa" -# content = "aa" - -# [[extra.landing_cards]] -# title = "" -# content = "" - -# [[extra.landing_cards]] -# title = "" -# content = "" - +[[extra.card]] +title = "Meet Likeminded People" +content = "Socialize other Rust enthusiasts and developers, share ideas, and make friends." +[[extra.card]] +title = "Free Food and Drinks" +content = "Each event includes free pizza and beer." +++ \ No newline at end of file diff --git a/static-site/templates/base.html b/static-site/templates/base.html index aa66bd8..83a75fb 100644 --- a/static-site/templates/base.html +++ b/static-site/templates/base.html @@ -1,20 +1,22 @@ {% import "macros.tera.html" as macros %} - - - - - - Tokyo Rust - - - {% include "navbar.html" %} -
-
{% block content %} {% endblock %}
-
- {% include "footer.html" %} - - - + + + + + + {{ config.title }} + + + + {% include "navbar.html" %} +
+
{% block content %} {% endblock %}
+
+ {% include "footer.html" %} + + + + \ No newline at end of file diff --git a/static-site/templates/footer.html b/static-site/templates/footer.html index 82465d3..d4476f2 100644 --- a/static-site/templates/footer.html +++ b/static-site/templates/footer.html @@ -1,50 +1,19 @@ - \ No newline at end of file diff --git a/static-site/templates/index.html b/static-site/templates/index.html index 664caca..8c2baba 100644 --- a/static-site/templates/index.html +++ b/static-site/templates/index.html @@ -4,11 +4,12 @@

{{ section.title }}

-

{{ config.extra[lang].about_us }}

+ +

{{ section.extra.about_us }}

{{ - config.extra[lang].join_next_event + section.extra.join_next_event }}
@@ -16,9 +17,9 @@

{{ section.t
-

{{ config.extra[lang].cards_header }}

+

{{ section.extra.cards_header }}

- {% for card in config.extra[lang].card %} + {% for card in section.extra.card %} {{ macros::landing_card(title=card.title, content=card.content) }} {% endfor %}
diff --git a/static-site/templates/macros.tera.html b/static-site/templates/macros.tera.html index cb48088..3068fff 100644 --- a/static-site/templates/macros.tera.html +++ b/static-site/templates/macros.tera.html @@ -21,3 +21,11 @@
{{ title }}
{{ url }}index.html {%- endif -%} {% endmacro get_url -%} + +{% macro social_link(name, url, icon) %} +
  • + + {{ name }} icon + +
  • +{% endmacro social_link %} \ No newline at end of file diff --git a/static-site/templates/navbar.html b/static-site/templates/navbar.html index 90b4cb3..5b60b95 100644 --- a/static-site/templates/navbar.html +++ b/static-site/templates/navbar.html @@ -8,22 +8,17 @@
    - + \ No newline at end of file