Scaffold Astro
Starting point
Section titled “Starting point”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.
Open an issue
Section titled “Open an issue”Create a GitHub issue, for example: Scaffold Astro sample and hygiene workflows.
Create a branch
Section titled “Create a branch”git fetch origingit checkout maingit pull origin maingit checkout -b feat/scaffold-astroScaffold Astro
Section titled “Scaffold Astro”Scaffold into this directory (not a nested folder):
npm create astro@latest . -- --template minimal --install --no-git --typescript strictConfirm a local build:
npm run buildls distKeep the site minimal: one page is enough. The goal is CI/CD, not content design.
Add amplify.yml
Section titled “Add amplify.yml”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: 1frontend: 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_BRANCHis set by Amplify (main,staging, or a PR branch name)- Non-
mainbuilds write a disallow-allrobots.txtso previews and staging are less likely to be indexed - Artifacts come from
dist/only - do not publishnode_modules
Full reference: amplify.yml.
Add hygiene workflows
Section titled “Add hygiene workflows”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@mainTarget layout
Section titled “Target layout”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
Commit, PR, wait, merge
Section titled “Commit, PR, wait, merge”Commits must pass commit message conformance: lowercase type, imperative header, body required.
git add .git commit -m "$(cat <<'EOF'feat: scaffold minimal astro sample for amplify
Add Astro minimal app, amplify.yml, and markdown-lint pluscommitmsg-conform workflows for pull request hygiene.EOF)"git push -u origin HEADOpen a pull request into main (link the issue with Closes #N), wait for checks to pass, then merge (squash is fine).
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` succeedsEOF)"gh pr checks --watchMerge only after checks are green. Do not push to main directly.
Next: GitHub branches and CI.