Skip to content

Commit

Permalink
Test workflow creating a PR
Browse files Browse the repository at this point in the history
  • Loading branch information
michalinacienciala committed Apr 26, 2023
1 parent 81baa4e commit 5d0f178
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
39 changes: 33 additions & 6 deletions .github/workflows/createPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,52 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create a pull request
shell: bash {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SUCC_COMMAND: "1"
run: |
echo "Configure"
git config --global user.email "michalina.cienciala@akena.co"
git config --global user.name "Michalina Cienciala"
echo "Checkout"
git checkout auto-update-api-docs || git checkout -b auto-update-api-docs
echo "Pull"
git pull
git checkout auto-update-api-docs-3 || git checkout -b auto-update-api-docs-3
# echo "Pull"
# git pull
echo "Edit"
date > newfile.txt
echo "Add"
git add -A
echo "Commit"
git commit -m "Update docs"
echo "Push"
git push --set-upstream origin HEAD:auto-update-api-docs
echo "PR"
hub pull-request -m "Update Solidity API docs" # --reviewer [...] --labels [...]
git push --set-upstream origin HEAD:auto-update-api-docs-3
echo "PR 1"
# set -x
# pr_command=$(hub pull-request --base main --message "Update Solidity API docs" --message "Docs updated by workflow:" 2>&1)
# echo "PR 2"
# if [ $? -eq 0 ] || [[ "$pr_command" == *"A pull request already exists"* ]];
# then
# echo "PR created (or it already existed)"
# else
# echo "PR creation command failed"
# exit 1
# fi
# if hub pull-request --base main --message "Update Solidity API docs" --message "Docs updated by workflow:" | grep -q "A pull request already exists"
# then
# echo "A pull request already exists"
# else
# echo "Pull request created"
# fi
if ./script.sh | grep -q "A pull request already exists"
then
echo "A pull request already exists"
else
echo "Pull request created"
fi
14 changes: 14 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

if [[ $SUCC_COMMAND == "0" ]];
then
echo "Success"
exit 0
elif [[ $SUCC_COMMAND == "1" ]];
then
echo "Error creating pull request: Unprocessable Entity (HTTP 422)"
echo "A pull request already exists for michalinacienciala:auto-update-api-docs-3."
exit 1
else
exit 2
fi

0 comments on commit 5d0f178

Please sign in to comment.