[MAPA-149] feat: uses lambda-pedido-acolhimento migrations to track mapa's database @ BONDE infra #8
Workflow file for this run
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 new schema to other repos | |
env: | |
USERNAME: ${{ github.actor }} | |
ADDRESS_SUFFIX: users.noreply.github.com | |
THE_SERVER: ${{ github.server_url }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- '**' | |
paths: | |
- 'schema.prisma' | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'schema.prisma' | |
jobs: | |
update-schema: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout current repository | |
uses: actions/checkout@v3 | |
- name: Checkout lambda-pedido-acolhimento | |
uses: actions/checkout@v3 | |
with: | |
repository: 'mapadoacolhimento/lambda-pedido-acolhimento' | |
ref: 'main' | |
path: 'lambda-pedido-acolhimento' | |
- name: Update schema file | |
working-directory: lambda-pedido-acolhimento | |
run: | | |
rm ./prisma/schema.prisma | |
cp -u ../schema.prisma ./prisma | |
- name: Check for changes | |
working-directory: lambda-pedido-acolhimento | |
run: | | |
if git diff --quiet; then | |
echo "No changes detected. Exiting." | |
echo "exiting=true" >> $GITHUB_ENV | |
fi | |
- name: Commit | |
if: env.exiting != 'true' | |
working-directory: lambda-pedido-acolhimento | |
run: | | |
git config user.name "$USERNAME" | |
git config user.email "$USERNAME@$ADDRESS_SUFFIX" | |
git checkout feat/use-remote-prisma-ref | |
git add prisma/schema.prisma | |
git commit -m "feat: updated schema.prisma file from $THE_SERVER/mapadoacolhimento/mapa-migrations." | |
- name: Push | |
if: env.exiting != 'true' | |
working-directory: lambda-pedido-acolhimento | |
run: | | |
git checkout feat/use-remote-prisma-ref | |
git push -u origin feat/use-remote-prisma-ref |