try to fetch login via gh api #20
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: update ndc-multitenant dependency | |
on: | |
push: | |
branches: | |
- main | |
- gil/fix-update-multitenant-dep | |
jobs: | |
send-pull-requests: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.HASURA_BOT_TOKEN }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: ndc-postgres | |
- name: Checkout multitenant repo | |
uses: actions/checkout@v4 | |
with: | |
repository: hasura/ndc-multitenant | |
path: ndc-multitenant | |
token: ${{ secrets.HASURA_BOT_TOKEN }} | |
- name: Setup cargo environment | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.72.0 | |
- name: Send pull-request | |
run: | | |
# get newest commit to use | |
pushd ndc-postgres | |
LATEST_SHA=$(git rev-parse --short HEAD) | |
AUTHOR_EMAIL=$(git show -s --format="%ae" HEAD) | |
popd | |
BRANCH_NAME="update-ndc-postgres-to-$LATEST_SHA" | |
DEP_FILEPATH="Cargo.toml" | |
# Change working directory to the repo folder | |
cd ndc-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 only for workspace | |
cargo update -w | |
# 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 | |
AUTHOR_USER=$(gh api search/users -f q="$AUTHOR_EMAIL") | |
# 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" \ | |
--assignee "$AUTHOR_USER" |