Skip to content

Scaffold Astro

You should already be in the cloned repo:

  • Directoryamplify-astro-cicd/ repo root (pwd)
    • Directory.git/
      • …
    • README.md

Do not push commits straight to main. Use an issue, a feature branch, a pull request, wait for checks, then merge.

Create a GitHub issue, for example: Scaffold Astro sample and hygiene workflows.

Terminal window
git fetch origin
git checkout main
git pull origin main
git checkout -b feat/scaffold-astro

Scaffold into this directory (not a nested folder):

Terminal window
npm create astro@latest . -- --template minimal --install --no-git --typescript strict

Confirm a local build:

Terminal window
npm run build
ls dist

Keep the site minimal: one page is enough. The goal is CI/CD, not content design.

Create amplify.yml
Root amplify.yml file that tells Amplify how to install, build, and which artifact directory to publish.
at the repository root:

version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
- |
if [ "${AWS_BRANCH}" != "main" ]; then
printf 'User-agent: *\nDisallow: /\n' > dist/robots.txt
fi
artifacts:
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*

Notes:

  • AWS_BRANCH is set by Amplify (main, staging, or a PR branch name)
  • Non-main builds write a disallow-all robots.txt so previews and staging are less likely to be indexed
  • Artifacts come from dist/ only - do not publish node_modules

Full reference: amplify.yml.

Create these under .github/workflows/ before the first PR (best practice; required for commit message checks):

.github/workflows/markdown-lint.yml:

name: Markdown Lint
on:
pull_request: {}
permissions:
statuses: write
checks: write
contents: read
pull-requests: read
jobs:
markdown-lint:
uses: actionsforge/actions/.github/workflows/markdown-lint.yml@main

.github/workflows/commitmsg-conform.yml:

name: Commit Message Conformance
on:
pull_request: {}
permissions:
statuses: write
checks: write
contents: read
pull-requests: read
jobs:
commitmsg-conform:
uses: actionsforge/actions/.github/workflows/commitmsg-conform.yml@main
  • Directoryamplify-astro-cicd/
    • Directory.git/
      • …
    • Directory.github/
      • Directoryworkflows/
        • commitmsg-conform.yml
        • markdown-lint.yml
    • amplify.yml
    • astro.config.mjs
    • package.json
    • package-lock.json
    • Directorypublic/
      • favicon.svg
    • README.md
    • Directorysrc/
      • Directorypages/
        • index.astro
    • tsconfig.json

Commits must pass commit message conformance: lowercase type, imperative header, body required.

Terminal window
git add .
git commit -m "$(cat <<'EOF'
feat: scaffold minimal astro sample for amplify
Add Astro minimal app, amplify.yml, and markdown-lint plus
commitmsg-conform workflows for pull request hygiene.
EOF
)"
git push -u origin HEAD

Open a pull request into main (link the issue with Closes #N), wait for checks to pass, then merge (squash is fine).

Terminal window
gh pr create --title "feat: scaffold minimal astro sample for amplify" --body "$(cat <<'EOF'
## Summary
- Scaffold minimal Astro app with amplify.yml
- Add markdown-lint and commitmsg-conform workflows
Closes #<issue-number>
## Test plan
- [ ] PR checks green (markdown-lint, commitmsg-conform)
- [ ] Local `npm run build` succeeds
EOF
)"
gh pr checks --watch

Merge only after checks are green. Do not push to main directly.

Next: GitHub branches and CI.