Skip to content

RA test 1

RA test 1 #50

Workflow file for this run

name: ReviewAPP
on:
pull_request
jobs:
build:
name: build the project
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: compile
run: |
# check py version
python --version
# compile the project
pip install -r lambdas/requirements.txt --platform manylinux2014_x86_64 --target tradingNewsLambda-package --only-binary=:all:
- name: prepare the package
run: |
# prepare the artifcat
cp lambdas/tradingNews-lambda.py tradingNewsLambda-package/tradingNews-lambda.py
cd tradingNewsLambda-package
zip -r tradingNewsLambda-package.zip .
aws s3 cp tradingNewsLambda-package.zip s3://oncobe-cf-packages/lambdas/tradingNewsLambda-package.zip
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_DEFAULT_REGION: 'us-east-1'
validation:
name: validate cloudformation template
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: display package
run: ls
- name: validate
run: aws cloudformation validate-template --template-body file://template.yaml
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_DEFAULT_REGION: 'us-east-1'
deploy:
name: deploy cloudformation template
runs-on: ubuntu-latest
needs: [validation]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: deploy
run: aws cloudformation deploy --stack-name rest-api --template-file template.yaml --capabilities CAPABILITY_IAM
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_DEFAULT_REGION: 'us-east-1'
output:
name: display the output of the deployment
runs-on: ubuntu-latest
needs: [deploy]
steps:
- name: github script
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_DEFAULT_REGION: 'us-east-1'
run: |
# Use GitHub API to create a comment on the PR
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
REST_API_ID=$(aws cloudformation --region us-east-1 describe-stacks --stack-name rest-api --query Stacks[0].Outputs[0].OutputValue --output text)
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"API gateway URL: https://${REST_API_ID}.execute-api.us-east-1.amazonaws.com\"}"