Merge pull request #8 from eltociear/patch-1 #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy main branch | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
pull_request_target: | |
types: | |
- closed | |
jobs: | |
deploy: | |
name: deploy | |
if: github.event_name != 'pull_request_target' || github.event.pull_request.merged != true | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install Serverless Framework | |
run: npm install serverless --global | |
- name: Install Dependencies | |
run: npm install | |
- name: Update domain settings | |
uses: mikefarah/yq@master | |
with: | |
cmd: | | |
yq -i '.stages.prod.params.customDomainName = "${{ vars.CUSTOM_DOMAIN_NAME }}"' serverless-compose.yml | |
yq -i '.stages.prod.params.customDomainCertificateARN = "${{ vars.CUSTOM_DOMAIN_CERTIFICATE_ARN }}"' serverless-compose.yml | |
- name: Serverless Deploy | |
uses: serverless/github-action@v4 | |
with: | |
args: deploy --stage ${{ github.event.pull_request.number && 'pr-${{ github.event.pull_request.number }}' || 'prod' }} | |
env: | |
SERVERLESS_LICENSE_KEY: ${{ secrets.SERVERLESS_LICENSE_KEY }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
remove: | |
name: remove | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install Serverless Framework | |
run: npm install serverless --global | |
- uses: bahmutov/npm-install@v1 | |
with: | |
working-directory: | | |
ai-chat-api | |
auth | |
business-api | |
business-worker | |
website | |
- name: serverless remove | |
uses: serverless/github-action@v4 | |
with: | |
args: remove --stage pr-${{ github.event.pull_request.number }} | |
env: | |
SERVERLESS_LICENSE_KEY: ${{ secrets.SERVERLESS_LICENSE_KEY }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |