Github Actions -多分支- AWS S3静态站点



我正在与Github Actions合作,将我的网站推送到S3以进行持续集成。它在我的主要分支机构工作。我想让它把站点分支代码推送到我的质量保证桶。

主分支->现场生产S3桶QA分公司->QA S3桶

名称:上传网站

on:
  push:
    branches:
    - master
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v1
    - name: Configure AWS Credentials
      uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: us-east-2
    - name: Deploy static site to S3 bucket
      run: aws s3 sync . s3://PROD_Bucket --delete

我尝试了以下操作,但失败了。我不确定我是否误解了yaml的逻辑。

name: Upload Website
on:
  push:
    branches:
    - master
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v1
- name: Configure AWS Credentials
  uses: aws-actions/configure-aws-credentials@v1
  with:
    aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
    aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    aws-region: us-east-2
- name: Deploy static site to S3 bucket
  run: aws s3 sync . s3://PROD_Bucket --delete
on:
  push:
    branches:
    - QA
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v1
    - name: Configure AWS Credentials
      uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: us-east-2
    - name: Deploy static site to S3 bucket
      run: aws s3 sync . s3://QA_Bucket --delete

是否有一种简单的方法说"当提交到QA时,转到bucket_2。当提交到main时,转到bucket_1"?

哦,你只需要在root/.github/workflows/

下添加第二个yaml这将是您想要白名单的第二个分支。咄。

相关内容

  • 没有找到相关文章