-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
6,843 additions
and
13,482 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: Test and Deploy | ||
|
||
on: | ||
push: | ||
branches: [main, dev, test] | ||
|
||
jobs: | ||
|
||
run-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1-node16 | ||
with: | ||
aws-access-key-id: ${{ secrets.SLS_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.SLS_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
|
||
# Set up Python 3.9 environment | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
# Install Python dependencies | ||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
# Run tests | ||
- name: Run tests | ||
run: python -m pytest | ||
|
||
|
||
deploy: | ||
needs: | ||
- run-tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
# Configure the deployment stage name from the active branch | ||
- name: Set up deployment stage name | ||
id: deployment-stage | ||
run: | | ||
echo "DEPLOY_STAGE=${{ fromJSON('{"main":"prod","dev":"dev","test":"test"}')[github.ref_name] }}" >> $GITHUB_ENV | ||
- name: Verify Stage | ||
run: echo $DEPLOY_STAGE | ||
|
||
# Checks-out the repository under $GITHUB_WORKSPACE | ||
- uses: actions/checkout@v2 | ||
|
||
# Configure Auth0 secrets | ||
- name: Create public_key file | ||
run: | | ||
cat > /home/runner/work/photonranch-api/photonranch-api/public_key << EOF | ||
-----BEGIN CERTIFICATE----- | ||
${{ secrets.AUTH0_PUBLIC_KEY }} | ||
-----END CERTIFICATE----- | ||
EOF | ||
- name: Create Auth0 secrets file | ||
run: | | ||
cat > /home/runner/work/photonranch-api/photonranch-api/secrets.json << EOF | ||
{ | ||
"AUTH0_CLIENT_ID": "${{ secrets.AUTH0_CLIENT_ID }}" | ||
} | ||
EOF | ||
# Set up Node | ||
- name: Set up Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
|
||
# Set up Python 3.9 environment | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
# Install serverless | ||
- name: Install Serverless | ||
run: npm install -g serverless | ||
|
||
# Install Node dependencies | ||
- name: Set up Environment | ||
run: npm ci | ||
|
||
# Install Serverless plugins | ||
- name: Install Plugins | ||
run: | | ||
serverless plugin install --name serverless-python-requirements && | ||
serverless plugin install --name serverless-domain-manager && | ||
serverless plugin install --name serverless-prune-plugin && | ||
serverless plugin install --name serverless-offline | ||
# Deploy to stage | ||
- name: Serverless Deploy | ||
run: serverless deploy --stage $DEPLOY_STAGE | ||
env: | ||
SERVERLESS_ACCESS_KEY: ${{ secrets.SLS_SECRET_KEY }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.SLS_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.SLS_AWS_SECRET_ACCESS_KEY }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.