feat: path validation if running locally #94
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 | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
outputs: | |
frontend: ${{ steps.frontend.outputs.front }} | |
places: ${{ steps.places.outputs.places }} | |
scraper: ${{ steps.scraper.outputs.scraper }} | |
branch: ${{ steps.extract_branch.outputs.branch }} | |
steps: | |
- name: Commit Checkout | |
uses: actions/checkout@v2 | |
- name: Extract branch name | |
id: extract_branch | |
run: echo "::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})" | |
- uses: dorny/paths-filter@v2 | |
id: places | |
with: | |
filters: | | |
places: | |
- 'places/**' | |
base: ${{ steps.extract_branch.outputs.branch }} | |
- uses: dorny/paths-filter@v2 | |
id: scraper | |
with: | |
filters: | | |
scraper: | |
- 'scraper/**' | |
base: ${{ steps.extract_branch.outputs.branch }} | |
- uses: dorny/paths-filter@v2 | |
id: frontend | |
with: | |
filters: | | |
front: | |
- 'frontend/**' | |
base: ${{ steps.extract_branch.outputs.branch }} | |
places: | |
if: ${{ needs.changes.outputs.places == 'true' }} | |
name: Deploy places service | |
needs: changes | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Load ".env" file to prisma connection | |
run: echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" > .env | |
working-directory: ./places/ | |
- name: Install code dependencies | |
run: npm ci | |
working-directory: ./places/ | |
- name: Generate Prisma Clinet | |
run: npm run prisma:start | |
working-directory: ./places/ | |
- name: serverless deploy | |
uses: serverless/github-action@v3.2 | |
with: | |
args: -c "cd places && serverless deploy" | |
entrypoint: /bin/sh | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
scraper: | |
if: ${{ needs.changes.outputs.scraper == 'true' }} | |
name: Deploy scraper service | |
needs: changes | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install code dependencies | |
run: npm ci | |
working-directory: ./scraper/ | |
- name: serverless deploy | |
uses: serverless/github-action@v3.2 | |
with: | |
args: -c "cd scraper && serverless deploy" | |
entrypoint: /bin/sh | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
frontend: | |
if: ${{ needs.changes.outputs.frontend == 'true' }} | |
needs: changes | |
name: Deploy Frontend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Commit Checkout | |
uses: actions/checkout@v2 | |
- name: Setup node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: '20.x' | |
- name: install dependencies | |
run: npm ci | |
working-directory: ./frontend | |
- name: build app | |
run: npm run build | |
working-directory: ./frontend | |
- name: Deploy with jakejarvis/s3-sync-action@master | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read --follow-symlinks --delete | |
env: | |
AWS_S3_BUCKET: ${{ secrets.AWS_BUCKET }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: 'sa-east-1' | |
SOURCE_DIR: 'frontend/dist' | |