Reputation: 1456
I'm working with Github Actions to push my site to S3 for continuous integration. Its working for my main branch. Was looking to have it push the site branch code to my Quality Assurance bucket.
Main branch -> live production S3 bucket QA branch -> QA S3 bucket
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
I tried the following but it fails. I'm not sure if I'm misunderstanding the logic of the 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
Is there an easy way to say "when commit is made to QA, go to bucket_2. When commit is made to main, go to bucket_1"?
Upvotes: 0
Views: 569
Reputation: 1456
Oh, you just need a second yaml under root/.github/workflows/
It would just be the second branch you want to whitelist. Duh.
Upvotes: 1