Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Archiving repository #132

Archiving repository

Archiving repository #132

Workflow file for this run

name: "Pipeline"
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency: main_workflow
permissions:
contents: write
pages: write
checks: write
id-token: write
packages: write
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install Postman CLI
run: |
curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh
- name: Login to Postman CLI
run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}
- name: Add .env file
uses: SpicyPizza/[email protected]
with:
envkey_AUTH0_AUDIENCE: ${{ secrets.BACKEND_AUTH0_AUDIENCE }}
envkey_AUTH0_BASE_URL: ${{ secrets.BACKEND_AUTH0_BASE_URL }}
envkey_MONGO_URL: mongodb://mongo:27017
directory: .
file_name: .env
fail_on_empty: true
- name: Run Docker image
run: |
npm run app
#
- name: Sleep for 20 seconds
run: sleep 20s
shell: bash
# - name: Run 500 API tests
# run: |
# postman collection run "${{ github.workspace }}/postman/collections/Sudokuru-Backend-500s.json"
- name: Run API tests
run: |
postman collection run "${{ github.workspace }}/postman/collections/Sudokuru-Backend.json" -e "${{ secrets.POSTMAN_ENV_ID }}"
- name: Dump mongo logs
if: failure()
uses: jwalton/gh-docker-logs@v2
deploy_docker_image:
name: Deploy Docker Image
if: ${{ github.ref == 'refs/heads/main' }}
needs: [ test ]
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Add .env file
uses: SpicyPizza/[email protected]
with:
envkey_AUTH0_AUDIENCE: ${{ secrets.BACKEND_AUTH0_AUDIENCE }}
envkey_AUTH0_BASE_URL: ${{ secrets.BACKEND_AUTH0_BASE_URL }}
envkey_MONGO_URL: mongodb://mongo:27017
directory: .
file_name: .env
fail_on_empty: true
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: ${{ github.repository }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
tags: "latest,${{ github.run_number }}"
deploy_documentation:
name: Deploy Documentation
if: ${{ github.ref == 'refs/heads/main' }}
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm ci
- run: npm run update-docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: 'docs/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
deploy:
name: Deploy to AWS Lambda
if: ${{ github.ref == 'refs/heads/main' }}
needs: [ deploy_documentation, deploy_docker_image ]
runs-on: ubuntu-latest
strategy:
matrix:
environment: [ dev, prod ]
environment: ${{ matrix.environment }}
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Add .env file
uses: SpicyPizza/[email protected]
with:
envkey_AUTH0_AUDIENCE: ${{ secrets.AUTH0_AUDIENCE }}
envkey_AUTH0_BASE_URL: ${{ secrets.AUTH0_BASE_URL }}
envkey_MONGO_URL: ${{secrets.DATABASE_URL}}
directory: .
file_name: .env
fail_on_empty: true
- run: npm ci
- run: npm i serverless
- name: ${{ matrix.environment }} Deployment
run: npm run deploy
env:
STAGE: ${{ matrix.environment }}