Add more comprehensive error logging, add JWT_SECRET to github action… #77
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: Deployment Pipeline | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
- workflow-testing | |
pull_request: | |
branches: [main] | |
types: [opened, synchronize] | |
jobs: | |
test_lint_backend: | |
runs-on: ubuntu-20.04 | |
defaults: | |
run: | |
working-directory: backend | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: create .env file | |
run: | | |
touch .env | |
echo DEV_MONGODB_URI=${{ secrets.DEV_MONGODB_URI }} >> .env | |
echo CLOUDINARY_NAME=${{ secrets.CLOUDINARY_NAME }} >> .env | |
echo CLOUDINARY_API_KEY=${{ secrets.CLOUDINARY_API_KEY }} >> .env | |
echo CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }} >> .env | |
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env | |
- name: npm install | |
run: npm install | |
- name: lint | |
run: npm run lint | |
- name: test | |
run: npm test | |
test_lint_frontend: | |
runs-on: ubuntu-20.04 | |
defaults: | |
run: | |
working-directory: frontend | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: npm install | |
run: npm install | |
- name: lint | |
run: npm run lint | |
- name: test | |
run: npm test | |
- name: install backend dependencies, create .env (for cypress to run) | |
run: | | |
cd ../backend | |
touch .env | |
echo DEV_MONGODB_URI=${{ secrets.DEV_MONGODB_URI }} >> .env | |
echo CLOUDINARY_NAME=${{ secrets.CLOUDINARY_NAME }} >> .env | |
echo CLOUDINARY_API_KEY=${{ secrets.CLOUDINARY_API_KEY }} >> .env | |
echo CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }} >> .env | |
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env | |
npm install | |
- name: cypress tests | |
uses: cypress-io/github-action@v2 | |
with: | |
start: npm run server:test, npm start | |
wait-on: 'http://localhost:3001/health, http://localhost:3000' | |
working-directory: ./frontend | |
build: | |
runs-on: ubuntu-20.04 | |
defaults: | |
run: | |
working-directory: backend | |
needs: [test_lint_backend, test_lint_frontend] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: npm install | |
run: npm install | |
- name: install frontend dependencies | |
run: cd ../frontend && npm install | |
- name: build ui | |
run: npm run build:ui | |
deploy: | |
if: ${{ github.ref == 'refs/head/main' }} | |
runs-on: ubuntu-20.04 | |
needs: [build] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: akhileshns/[email protected] | |
with: | |
heroku_api_key: ${{secrets.HEROKU_API_KEY}} | |
heroku_app_name: "instaclone-sc" | |
heroku_email: "[email protected]" | |
appdir: "backend" | |
healthcheck: "" | |
checkstring: "ok" | |
rollbackonhealthcheckfailed: true | |
tag_release: | |
if: ${{ github.ref == 'refs/head/main' }} | |
needs: [deploy] | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: '0' | |
- name: Bump version and push tag | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# for deploying, make sure to have all final dependencies installed before deploying at all. aka, don't deploy, realize you need a new dep and then deploy again | |
# todo: research how i can add new packages after deployment and then redeploy |