如何使用GitHub工作流程将工件部署到AWS S3?
我有两个用于CI的工作流,另一个用于CD。工作是将静态网站部署到S3存储桶中。它应该在CI生成的工件中部署文件。我想将工件和解压缩下载到我的存储库中的目录,然后将我的CD上传www目录中的文件中的S3中的文件以进行静态Web托管。
这是CI脚本
name: ci
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 12.8
cache: 'npm'
- name: npm dependencies
run: npm install
- name: run
run: npm run build --if-present
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist-without-markdown
path: |
www
这是CD脚本。
name: cd
on:
workflow_run:
workflows: ["ci"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: udagram-frontend-sm
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: 'www' # optional: defaults to entire repository
I have two workflows one for ci and one for cd. The job is to deploy a static website to and s3 bucket. It should deploy the files within the artifact generated from the ci. I want to download the artifact and unzip to a directory inside my repository, this will then allow my cd to upload the files inside the www directory to s3 for static web hosting.
Here is the ci script
name: ci
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 12.8
cache: 'npm'
- name: npm dependencies
run: npm install
- name: run
run: npm run build --if-present
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist-without-markdown
path: |
www
Here is the cd script.
name: cd
on:
workflow_run:
workflows: ["ci"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: udagram-frontend-sm
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: 'www' # optional: defaults to entire repository
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用另一个动作下载工件。
You could use another action to download the artifact.