Skip to content

Introduce v2 of auto-generated mutations (#513) #361

Introduce v2 of auto-generated mutations (#513)

Introduce v2 of auto-generated mutations (#513) #361

name: update multitenant dependency
on:
push:
branches:
- main
jobs:
send-pull-requests:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.HASURA_BOT_TOKEN }}
steps:
- name: check out this repository
uses: actions/checkout@v4
with:
path: ndc-postgres
- name: check out ndc-postgres-multitenant
uses: actions/checkout@v4
with:
repository: hasura/ndc-postgres-multitenant
path: ndc-postgres-multitenant
token: ${{ secrets.HASURA_BOT_TOKEN }}
- name: install tools for ndc-postgres-multitenant
working-directory: ndc-postgres-multitenant
run: |
rustup show
- name: send pull request
run: |
set -eux
# get newest commit to use
LATEST_SHA="$(cd ndc-postgres && git rev-parse HEAD)"
BRANCH_NAME="update-ndc-postgres-to-$LATEST_SHA"
DEP_FILEPATH="Cargo.toml"
# Change working directory to the target folder
cd ndc-postgres-multitenant
git config --global user.name "hasura-bot"
git config --global user.email "[email protected]"
# Create a new feature branch for the changes.
git checkout -b $BRANCH_NAME
# Update the hash to the latest version.
sed -i -e '/ndc-postgres.git/s/rev[ ]*=[ ]*"[[:alnum:]]*"/rev = "'"$LATEST_SHA"'"/g' $DEP_FILEPATH
# ssh git access required for cargo update
eval "$(ssh-agent -s)"
ssh-add - <<< '${{ secrets.SSH_GIT_ACCESS_PRIVATE }}'
# Update Cargo lock file, but as little as possible
cargo update -p ndc-postgres
# Commit the changes and push the feature branch to origin
git add .
git commit -m "dep update: update ndc-postgres to $LATEST_SHA"
git push origin $BRANCH_NAME
# create a pull-requests containing the updates.
gh pr create \
--body "Commit in ndc-postgres: https://github.com/hasura/ndc-postgres/commit/$LATEST_SHA" \
--title "dep update: update ndc-postgres to $LATEST_SHA" \
--head "$BRANCH_NAME" \
--base "main" \
--reviewer "hasura/native-databases"
# scream into Slack if something goes wrong
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: failure
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}