Skip to content

Commit 7b9f2dc

Browse files
author
decobot
committed
bumps deco to test redis cache and compression
1 parent 4b32f61 commit 7b9f2dc

28 files changed

Lines changed: 220 additions & 6095 deletions

.github/workflows/README.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,36 @@
22

33
## Overview
44

5-
The `build-and-push-image.yaml` workflow builds the storefront Docker image and pushes it to Amazon ECR when changes are merged to the `main` branch via PR.
5+
The `build-and-push-image.yaml` workflow builds the storefront Docker image and
6+
pushes it to Amazon ECR when changes are merged to the `main` branch via PR.
67

78
## When the build runs
89

910
- **Push to `main`** on relevant files:
1011
- `Dockerfile`
11-
- Application code: `actions/`, `apps/`, `components/`, `loaders/`, `routes/`, `sections/`, `sdk/`, `static/`
12+
- Application code: `actions/`, `apps/`, `components/`, `loaders/`, `routes/`,
13+
`sections/`, `sdk/`, `static/`
1214
- Config: `main.ts`, `dev.ts`, `deno.json`, `fresh.config.ts`, etc.
1315
- **Manual**: via `workflow_dispatch` in the GitHub Actions tab
1416

1517
## Required configuration
1618

1719
### 1. Variables (Settings > Secrets and variables > Actions > Variables)
1820

19-
| Variable | Description | Example |
20-
|----------|-------------|---------|
21-
| `AWS_ACCOUNT_ID` | AWS account ID for ECR | `123456789012` |
22-
| `AWS_REGION` | ECR region | `sa-east-1` |
23-
|| ECR repository name is taken from `DECO_SITE_NAME` in the Dockerfile (no need to set) ||
21+
| Variable | Description | Example |
22+
| ---------------- | ------------------------------------------------------------------------------------- | -------------- |
23+
| `AWS_ACCOUNT_ID` | AWS account ID for ECR | `123456789012` |
24+
| `AWS_REGION` | ECR region | `sa-east-1` |
25+
| | ECR repository name is taken from `DECO_SITE_NAME` in the Dockerfile (no need to set) | |
2426

2527
### 2. AWS authentication
2628

2729
**Option A - OIDC (recommended):**
2830

29-
1. Configure OIDC in AWS per [GitHub docs](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)
30-
2. Create an IAM role with ECR permissions (`ecr:GetAuthorizationToken`) and push policy
31+
1. Configure OIDC in AWS per
32+
[GitHub docs](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)
33+
2. Create an IAM role with ECR permissions (`ecr:GetAuthorizationToken`) and
34+
push policy
3135
3. Add secret `ECR_ACCESS_ROLE_ARN` = `arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME`
3236

3337
**Option B - Access Keys:**
@@ -36,39 +40,56 @@ The `build-and-push-image.yaml` workflow builds the storefront Docker image and
3640
2. In **Settings > Secrets and variables > Actions > Secrets**, add:
3741
- `ECR_CI_AWS_ACCESS_KEY_ID`
3842
- `ECR_CI_AWS_SECRET_ACCESS_KEY`
39-
3. The workflow uses Access Keys by default; for OIDC, comment out the Access Keys step and uncomment the OIDC step
43+
3. The workflow uses Access Keys by default; for OIDC, comment out the Access
44+
Keys step and uncomment the OIDC step
4045

4146
### 3. ECR repository
4247

43-
The repository name is taken from `DECO_SITE_NAME` in the Dockerfile. The pipeline checks if the repo exists and **creates it automatically on first run** if not. No need to create it manually.
48+
The repository name is taken from `DECO_SITE_NAME` in the Dockerfile. The
49+
pipeline checks if the repo exists and **creates it automatically on first run**
50+
if not. No need to create it manually.
4451

45-
The IAM role/user must have: `ecr:CreateRepository`, `ecr:DescribeRepositories`, `ecr:SetRepositoryPolicy`, and standard push permissions (`ecr:GetAuthorizationToken`, `ecr:BatchCheckLayerAvailability`, `ecr:PutImage`, etc.).
52+
The IAM role/user must have: `ecr:CreateRepository`, `ecr:DescribeRepositories`,
53+
`ecr:SetRepositoryPolicy`, and standard push permissions
54+
(`ecr:GetAuthorizationToken`, `ecr:BatchCheckLayerAvailability`, `ecr:PutImage`,
55+
etc.).
4656

4757
### 4. Cross-account policy (optional, no account IDs in repo)
4858

49-
To allow **cross-account pull** (and write/Lambda per your policy) **without putting account IDs in the public repo**, use a variable:
59+
To allow **cross-account pull** (and write/Lambda per your policy) **without
60+
putting account IDs in the public repo**, use a variable:
5061

51-
1. In **Settings > Secrets and variables > Actions > Variables**, create the variable **`ECR_REPOSITORY_POLICY_JSON`**.
52-
2. Paste as value the full ECR repository policy JSON (including ARNs with account IDs and, if used, the `LambdaECRImageCrossAccountRetrievalPolicy` condition).
62+
1. In **Settings > Secrets and variables > Actions > Variables**, create the
63+
variable **`ECR_REPOSITORY_POLICY_JSON`**.
64+
2. Paste as value the full ECR repository policy JSON (including ARNs with
65+
account IDs and, if used, the `LambdaECRImageCrossAccountRetrievalPolicy`
66+
condition).
5367

54-
The workflow applies this policy **only on the first run**, when the ECR repository is created. On subsequent runs the step is skipped. If the variable is not set, the step is skipped and no custom policy is applied.
68+
The workflow applies this policy **only on the first run**, when the ECR
69+
repository is created. On subsequent runs the step is skipped. If the variable
70+
is not set, the step is skipped and no custom policy is applied.
5571

5672
## Resulting image
5773

5874
- **Multi-arch**: linux/amd64 and linux/arm64 (manifest list created by buildx)
59-
- **Semantic tag**: `{registry}/storefront:1.0.0` (patch auto-incremented per release: 1.0.0 → 1.0.1 → 1.0.2)
75+
- **Semantic tag**: `{registry}/storefront:1.0.0` (patch auto-incremented per
76+
release: 1.0.0 → 1.0.1 → 1.0.2)
6077
- **Latest tag**: `{registry}/storefront:latest`
6178
- **Build arg** `GIT_REVISION`: full commit SHA (for traceability)
6279

6380
## GitHub Release
6481

6582
On each successful build, a release is created in the repo with:
83+
6684
- Tag in the form `v1.0.0`
6785
- Auto-generated release notes
6886
- Reference to the Docker image published to ECR
6987

70-
The next version number is derived from the latest existing tag (patch increment).
88+
The next version number is derived from the latest existing tag (patch
89+
increment).
7190

7291
## Monorepo
7392

74-
If the storefront lives in a monorepo (subdirectory), move the workflow to `.github/workflows/` at the repo root and adjust `paths` and Docker `context`/`file` to include the `storefront/` prefix.
93+
If the storefront lives in a monorepo (subdirectory), move the workflow to
94+
`.github/workflows/` at the repo root and adjust `paths` and Docker
95+
`context`/`file` to include the `storefront/` prefix.

_deno.serve.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import { ServerContext } from "$fresh/server.ts";
77
import config from "./fresh.config.ts";
88
import manifest from "./fresh.gen.ts";
99

10-
const ctx = await ServerContext.fromManifest(manifest, { ...config, dev: false });
10+
const ctx = await ServerContext.fromManifest(manifest, {
11+
...config,
12+
dev: false,
13+
});
1114

1215
export default {
1316
fetch: ctx.handler(),
14-
}
17+
};

actions/minicart/submit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const cartFrom = (form: FormData) => {
5050
addToCart: null,
5151
};
5252

53-
for (const [name, value] of form.entries()) {
53+
form.forEach((value, name) => {
5454
if (name === "coupon") {
5555
cart.coupon = value.toString();
5656
} else if (name === "action") {
@@ -63,7 +63,7 @@ const cartFrom = (form: FormData) => {
6363
} else if (name === "add-to-cart") {
6464
cart.addToCart = safeParse(decodeURIComponent(value.toString()));
6565
}
66-
}
66+
});
6767

6868
return cart;
6969
};

components/minicart/Coupon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ function Coupon({ coupon }: Props) {
2929
class="input join-item"
3030
type="text"
3131
value={coupon ?? ""}
32-
placeholder={"Cupom"}
32+
placeholder="Cupom"
3333
/>
3434
<button
35+
type="submit"
3536
form={MINICART_FORM_ID}
3637
class="btn join-item"
3738
name="action"

components/minicart/Item.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function CartItem({ item, index, locale, currency }: Props) {
5151
<div class="flex justify-between items-center">
5252
<legend>{name}</legend>
5353
<button
54+
type="button"
5455
class={clx(
5556
isGift && "hidden",
5657
"btn btn-ghost btn-square no-animation",

components/minicart/Minicart.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export function ErrorFallback() {
8181
</div>
8282

8383
<button
84+
type="button"
8485
class="btn btn-primary"
8586
hx-patch={useComponent(import.meta.url)}
8687
hx-swap="outerHTML"
@@ -127,11 +128,11 @@ export default function Cart(
127128
hx-swap="outerHTML"
128129
>
129130
{/* Button to submit the form */}
130-
<button hidden autofocus />
131+
<button type="submit" hidden autofocus />
131132

132133
{/* Add to cart controllers */}
133134
<input name="add-to-cart" type="hidden" />
134-
<button hidden name="action" value="add-to-cart" />
135+
<button type="submit" hidden name="action" value="add-to-cart" />
135136

136137
{/* This contains the STOREFRONT cart. */}
137138
<input

components/product/AddToCartButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function AddToCartButton(props: Props) {
119119
<input type="checkbox" class="hidden peer" />
120120

121121
<button
122+
type="button"
122123
disabled
123124
class={clx("flex-grow peer-checked:hidden", _class?.toString())}
124125
hx-on:click={useScript(onClick)}

components/product/OutOfStock.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function Notify({ productID }: Props) {
3737
<input placeholder="Nome" class="input input-bordered" name="name" />
3838
<input placeholder="Email" class="input input-bordered" name="email" />
3939

40-
<button class="btn btn-primary no-animation">
40+
<button type="button" class="btn btn-primary no-animation">
4141
<span class="[.htmx-request_&]:hidden inline">Enviar</span>
4242
<span class="[.htmx-request_&]:inline hidden loading loading-spinner loading-xs" />
4343
</button>

components/search/Filters.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function FilterValues({ key, values }: FilterToggle) {
3939

4040
if (avatars) {
4141
return (
42-
<a href={url} rel="nofollow">
42+
<a key={url} href={url} rel="nofollow">
4343
<Avatar
4444
content={value}
4545
variant={selected ? "active" : "default"}
@@ -53,13 +53,14 @@ function FilterValues({ key, values }: FilterToggle) {
5353

5454
return range && (
5555
<ValueItem
56+
key={item.value}
5657
{...item}
5758
label={`${formatPrice(range.from)} - ${formatPrice(range.to)}`}
5859
/>
5960
);
6061
}
6162

62-
return <ValueItem {...item} />;
63+
return <ValueItem key={item.url} {...item} />;
6364
})}
6465
</ul>
6566
);

components/search/SearchResult.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ const useUrlRebased = (overrides: string | undefined, base: string) => {
4141
const temp = new URL(overrides, base);
4242
const final = new URL(base);
4343
final.pathname = temp.pathname;
44-
for (const [key, value] of temp.searchParams.entries()) {
44+
temp.searchParams.forEach((value, key) => {
4545
final.searchParams.set(key, value);
46-
}
46+
});
4747
url = final.href;
4848
}
4949
return url;

0 commit comments

Comments
 (0)