Merge pull request #46 from mapadoacolhimento/feat/adds-support-evalu… #44
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: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'postgres/schema.prisma' | |
jobs: | |
update-schema-postgres: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
repositories: [lambda-pedido-acolhimento, cadastro-msr, lambda-confirmacao-disponibilidade, boas-vindas-chatbot] | |
steps: | |
- name: Checkout current repository | |
uses: actions/checkout@v3 | |
- name: Checkout lambda-pedido-acolhimento | |
uses: actions/checkout@v3 | |
with: | |
repository: mapadoacolhimento/${{ matrix.repositories }} | |
ref: 'main' | |
path: ${{ matrix.repositories }} | |
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }} | |
- name: Update schema file | |
working-directory: ${{ matrix.repositories }} | |
run: | | |
if [ -d "./prisma/postgres/" ]; then | |
rm ./prisma/postgres/schema.prisma | |
cp -u ../postgres/schema.prisma ./prisma/postgres | |
elif [ -d "./packages/ui/prisma" ]; then | |
rm ./packages/ui/prisma/schema.prisma | |
cp -u ../postgres/schema.prisma ./packages/ui/prisma/postgres | |
else | |
rm ./prisma/schema.prisma | |
cp -u ../postgres/schema.prisma ./prisma | |
fi | |
- name: Check for changes | |
working-directory: ${{ matrix.repositories }} | |
run: | | |
if git diff --quiet; then | |
echo "No changes detected. Exiting." | |
echo "exiting=true" >> $GITHUB_ENV | |
fi | |
- name: Commit changes | |
if: env.exiting != 'true' | |
working-directory: ${{ matrix.repositories }} | |
run: | | |
git config user.name "$USERNAME" | |
git config user.email "$USERNAME@$ADDRESS_SUFFIX" | |
if [ -d "./prisma/postgres/" ]; then | |
git add prisma/postgres/schema.prisma | |
else | |
git add prisma/schema.prisma | |
fi | |
git commit -m "feat: updated schema.prisma file from $THE_SERVER/mapadoacolhimento/mapa-migrations/blob/main/postgres/schema.prisma" | |
- name: Push to main | |
if: env.exiting != 'true' | |
working-directory: ${{ matrix.repositories }} | |
run: git push origin main |