-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Github Actions job template that automates IaSQL code reviews #2360
Comments
Also, accepting a message in |
#2331 should be happen separately before or after this |
It's not possible to pass variables (Postgres database connection string in this case) to the PR merged event. Therefore we need to use a Github secret for this purpose. The user will need to set an |
SELECT iasql_begin();
INSERT INTO bucket (name) VALUES ('mtp-test-x-15');
|
create-pr.ymlname: 'IaSQL Create PR'
on:
workflow_dispatch:
inputs:
prTitle:
description: 'Title for the PR'
required: true
prDescription:
description: 'Description for the PR'
required: false
jobs:
create-pr:
name: Create PR - ${{ inputs.prTitle }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create markdown file
id: create-markdown
run: |
PR=$(psql "$CON_STR" -AXqtc "SELECT * FROM iasql_create_review('$PR_TITLE', '$PR_DESCRIPTION');")
mkdir -p transactions
cd transactions
echo "$PR" > "$PR_TITLE.md"
echo 'pr<<EOF' >> $GITHUB_OUTPUT
echo "$PR" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
env:
CON_STR: ${{ secrets.IASQL_PG_CONN_STR }}
PR_TITLE: ${{ inputs.prTitle }}
PR_DESCRIPTION: ${{ inputs.prDescription }}
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
commit-message: ${{ inputs.prTitle }}
delete-branch: false
title: ${{ inputs.prTitle }}
body: ${{ steps.create-markdown.outputs.pr }}
branch: iasql/code-review
branch-suffix: timestamp
base: 'main'
- name: Check outputs
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
pr-merged.ymlname: 'IaSQL Commit Changes on PR Merge'
on:
pull_request:
types:
- closed
jobs:
commit_changes:
name: Commit changes to IaSQL from merged PR
if: github.event.pull_request.merged == true && contains(github.head_ref, 'iasql/code-review-')
runs-on: ubuntu-latest
steps:
- name: Run iasql_commit
run: |
echo "Running iasql_commit"
COMMIT_RESULT=$(psql "$CON_STR" -AXqtc "SELECT * FROM iasql_commit('$PR_URL');")
echo "Commit result: $COMMIT_RESULT"
env:
CON_STR: ${{ secrets.IASQL_PG_CONN_STR }}
PR_URL: ${{ github.event.pull_request.url }} |
This looks great to me!
|
why need to remove the sslmode? |
Because the default |
Hmm I wonder if we should worry if it is not connecting with the db using SSL |
|
Sounds good, let's close this out and we can create another task to publish to Github Marketplace. I think it probably makes sense to publish each job separately to the GitHub marketplace? |
Yes. We should publish them separately. |
suggested by @yrobla. the Github actions job should take a pg connection string and assumes it will run on the repo it is in. It should have a button via
workflow_dispatch
hook that accepts a branch name to generate a PR on. markdown goes intransactions/
folder. Merging the PR triggers a CI job that callsiasql_commit
with the URL to the PR which includes #The text was updated successfully, but these errors were encountered: