Skip to content
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

PR is not created. Only branch is #107

Open
yalattas opened this issue Jun 19, 2024 · 0 comments
Open

PR is not created. Only branch is #107

yalattas opened this issue Jun 19, 2024 · 0 comments

Comments

@yalattas
Copy link

Describe the bug

documentation stating that PR should be created in case action triggered via different mechanism than PR. Mine is working on push on default branch.
I noticed that PR wasn't created. Yet, another branch named changelog-ci-main-1718765670 so I had to write extra step to open the PR and merge it. Yet, outputs doesn't have branch name. only change log content.

Therefore, I had to write an extra git command to get the branch based on pattern given that number of the branch is random

Your Environment

ubuntu-latest

Workflow Run URL (if Public Repository):
(Example: https://github.com/saadmk11/changelog-ci/actions/runs/1350256604)
Contents of Your Changelog-CI Workflow File (.yaml File):


on:
  push:
    branches:
      - hotfix/changelog

jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      discussions: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Get the latest tag
        id: get_tag
        run: |
          git fetch --tags
          LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
          echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT

      - name: Run Changelog CI
        uses: saadmk11/changelog-ci@v1.1.2
        id: changelog_ci
        continue-on-error: true
        with:
          changelog_filename: CHANGELOG.md
          committer_username: ${{ vars.CI_NAME }}
          committer_email: ${{ vars.CI_EMAIL }}
          github_token: ${{ secrets.GITHUB_TOKEN }}
          release_version: ${{ steps.get_tag.outputs.latest_tag }}

      - name: Get the latest branch matching the pattern
        id: get_branch
        run: |
          git fetch --all
          LATEST_BRANCH=$(git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/changelog-ci-* | head -n 1)
          echo "latest_branch=$LATEST_BRANCH" >> $GITHUB_OUTPUT

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v6
        id: pull_request
        continue-on-error: true
        with:
          title: "[CI]: update changelog for version ${{ steps.get_tag.outputs.latest_tag }}"
          commit-message: "[skip ci] update changelog for version ${{ steps.get_tag.outputs.latest_tag }}"
          committer: ${{ vars.CI_EMAIL }}
          author: ${{ vars.CI_NAME }}
          branch: ${{ steps.get_branch.outputs.latest_branch }}
          base: ${{ github.event.repository.default_branch }}

      - name: Merge Pull Request
        uses: juliangruber/merge-pull-request-action@v1
        continue-on-error: true
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          number: ${{ steps.pull_request.outputs.pull-request-number }}
          method: squash

      - name: Release
        uses: softprops/action-gh-release@v2
        with:
          body_path: ${{ steps.changelog_ci.outputs.changelog }}
          tag_name: ${{ steps.get_tag.outputs.latest_tag }}
          generate_release_notes: true

Contents of Changelog-CI Configuration File (If Applicable):

Expected behavior

To open a PR with a title and a body. Or provide newly created branch in output to carry the execution further

Actual behavior

Branch was created and not PR

Additional context

Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant