Scaffold Astro
Create the project
Section titled “Create the project”From an empty working directory (or into the existing amplify-astro-cicd clone):
npm create astro@latest amplify-astro-cicd -- --template minimal --install --no-git --typescript strictcd amplify-astro-cicdKeep the site minimal: one page is enough. The goal is CI/CD, not content design.
Confirm a local build:
npm run buildls distAdd 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.
Optional README stub
Section titled “Optional README stub”# amplify-astro-cicd
Minimal Astro site for Amplify staging PR previews and GitHub CINext: GitHub branches and CI.