Skip to content

Commit

Permalink
πŸ› οΈ Refactor PR creation to use environment variables
Browse files Browse the repository at this point in the history
This commit enhances the Pull Request creation process in our GitHub Action:

- πŸ“¦ Introduces environment variables `PR_TITLE` and `PR_BODY` to store PR content
- πŸ”„ Updates the action to use these environment variables instead of direct interpolation
- πŸ› Fixes potential issues with escaping special characters in PR title and body
- πŸš€ Improves maintainability and reduces the risk of syntax errors

These changes make our action more robust and easier to maintain. By using environment variables, we ensure that the PR title and body are properly handled, regardless of their content or length. This approach also simplifies debugging and allows for easier modifications in the future.
  • Loading branch information
yuri-val committed Oct 18, 2024
1 parent 5536ef9 commit ed5cf32
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,18 @@ runs:
- name: Create or Update Pull Request and Add Reviewers
id: create_pr
uses: actions/github-script@v6
env:
PR_TITLE: ${{ steps.set_release_title.outputs.title }}
PR_BODY: ${{ steps.generate_release_notes.outputs.description }}
with:
github-token: ${{ inputs.github_token }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const head = '${{ inputs.dev_branch }}';
const base = '${{ steps.get_default_branch.outputs.branch }}';
const title = '${{ steps.set_release_title.outputs.title }}';
const body = `${{ steps.generate_release_notes.outputs.description }}`;
const title = process.env.PR_TITLE;
const body = process.env.PR_BODY;
// Check if PR from dev to default branch already exists
const { data: pulls } = await github.rest.pulls.list({
Expand Down

0 comments on commit ed5cf32

Please sign in to comment.