我正在尝试使用AWS CodeBuild将所有文件和子文件夹放在嵌套public
文件夹中,并使用CodePipeline部署到S3存储桶。我能够将它们挂在一起,但是努力配置buildspec.yml
文件以获取所需的输出。
我的文件夹结构:
<path>/public/
├── 404.html
├── css
│ ├── ...
├── fonts
│ ├── bootstrap
│ │ ├── ...
│ ├── icomoon
│ │ ├── icomoon
│ │ │ ├── ...
│ └── simple-line-icons
│ ├── ...
├── images
│ ├── ...
├── index.html
├── index.xml
├── js
│ ├── ...
└── tags
└── index.xml
我需要将文件夹内的所有内容(包括子文件夹)public
放入S3存储桶的根目录中。
到目前为止,我已经尝试在这里,这里和这里关注文档。我试过使用:
**/*
以便以递归方式将所有内容保存在文件夹中,public
但S3存储桶将具有该文件夹的路径,因此index.html
不在根目录中。discard-paths: yes
删除public
文件夹的路径,但在S3存储桶中,所有文件都位于根目录中,不保留任何子文件夹结构。base-directory
:作为描述在这里。artifacts: secondary-artifacts: artifact1: files: - directory/file artifact2: files: - directory/file2
保持文件夹结构,但我的构建失败。我想出了一种解决方法。我认为这不是最好的方法,但是它可以工作。我希望您可以找到此解决方案有用buildspec.yml
:
version: 0.2
phases:
build:
commands:
- mkdir build-output
- cp -R <path>/public/ build-output
post_build:
commands:
- mv build-output/**/* ./
- mv build-output/* ./
- rm -R build-output *.yml LICENSE README* .git*
artifacts:
files:
- '**/*'
换句话说:
我将嵌套<path>/public
文件夹中的所有内容复制到名为的文件夹中./build-output
。
然后,post_build
将所有内容移出文件夹build-output
。
删除从GitHub存储库中提取的文件,这些文件对于将静态网站托管在GitHub中是不需要的 S3 bucket
然后,我得到想要的结果:带有正确的文件夹树public
的根目录中的所有文件S3 bucket
。
更新:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句