📚 Subject area/topic
Deployment docs
📋 Page(s) affected (or suggested, for new content)
https://docs.astro.build/en/guides/deploy/aws/#continuous-deployment-with-github-actions
📋 General description or bullet points (if proposing new content)
When deploying through Github actions, copy + pasting the code examples, static assets aren't deleted from the S3 bucket even if they don't appear in the /dist directory.
An example. I have some blog pages under /blog/[slug]. And under /pages/blog/[...slug].astro I have the pretty much the standard template:
export async function getStaticPaths() {
const mode = import.meta.env.MODE
let posts = await getCollection('blog');
if (mode === 'production') {
posts = posts.filter((post) => post.data.draft !== true)
}
return posts.map((post) => ({
params: { slug: post.slug },
props: post,
}));
}
type Props = CollectionEntry<'blog'>;
const post = Astro.props;
const { Content } = await post.render();
---
<BlogPost {...post.data}>
<Content />
</BlogPost>
now if I delete a blog post and run aws s3 sync ./dist/ s3://${{ secrets.BUCKET_ID }} it wont delete that route from the S3 bucket.
The suggested fix would be to use:
aws s3 sync --delete ./dist/ s3://${{ secrets.BUCKET_ID }}
and add IAM permissions to delete objects:
"s3:DeleteObject"
🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)
I tired to describe above how to reproduce. Not really possible with stackblitz since it's a CI/CD thing.
📚 Subject area/topic
Deployment docs
📋 Page(s) affected (or suggested, for new content)
https://docs.astro.build/en/guides/deploy/aws/#continuous-deployment-with-github-actions
📋 General description or bullet points (if proposing new content)
When deploying through Github actions, copy + pasting the code examples, static assets aren't deleted from the S3 bucket even if they don't appear in the
/distdirectory.An example. I have some blog pages under
/blog/[slug]. And under/pages/blog/[...slug].astroI have the pretty much the standard template:now if I delete a blog post and run
aws s3 sync ./dist/ s3://${{ secrets.BUCKET_ID }}it wont delete that route from the S3 bucket.The suggested fix would be to use:
aws s3 sync --delete ./dist/ s3://${{ secrets.BUCKET_ID }}and add IAM permissions to delete objects:
"s3:DeleteObject"🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)
I tired to describe above how to reproduce. Not really possible with stackblitz since it's a CI/CD thing.