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

Add more check for PR's merged during release #1447

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ jobs:

- name: Check if any PR was merged during release
run: |
COMMIT_SHA=$(gh api repos/${{ env.KYMA_ENVIRONMENT_BROKER_REPO }}/commits/main -q '.sha')
COMMIT_SHA=$(gh api repos/${{ env.KYMA_ENVIRONMENT_BROKER_REPO }}/commits -q '.[0].sha')
echo "Latest commit sha: $COMMIT_SHA"
echo "Workflow sha: ${{ github.sha }}"
if [ "$COMMIT_SHA" != "${{ github.sha }}" ]; then
Expand Down Expand Up @@ -268,6 +268,16 @@ jobs:
echo "Step skipped"
fi

- name: Check if any PR have been merged before merging the bump PR
run: |
COMMIT_SHA=$(gh api repos/${{ env.KYMA_ENVIRONMENT_BROKER_REPO }}/commits -q '.[1].sha')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check the commit before the PR bump

echo "Latest commit sha: $COMMIT_SHA"
echo "Bump sha: ${{ github.sha }}"
if [ "$COMMIT_SHA" != "${{ github.sha }}" ]; then
echo "::error ::a PR have been merged before merging the bump PR. Don't rerun this workflow. Create a new release with the same version"
exit 1
fi

- name: Save latest commit ref
id: pull-ref
env:
Expand Down Expand Up @@ -296,7 +306,7 @@ jobs:

- name: Check if any PR was merged after bumps
run: |
COMMIT_SHA=$(gh api repos/${{ env.KYMA_ENVIRONMENT_BROKER_REPO }}/commits/main -q '.sha')
COMMIT_SHA=$(gh api repos/${{ env.KYMA_ENVIRONMENT_BROKER_REPO }}/commits -q '.[0].sha')
echo "Latest commit sha: $COMMIT_SHA"
echo "Bump sha: ${{ needs.bumps.outputs.latest_commit}}"
if [ "$COMMIT_SHA" != "${{ needs.bumps.outputs.latest_commit}}" ]; then
Expand All @@ -318,6 +328,16 @@ jobs:
git tag ${{ github.event.inputs.name }}
git push origin ${{ github.event.inputs.name }}

- name: Check if any PR may have been merged before creating the tag and draft release
run: |
COMMIT_SHA=$(gh api repos/${{ env.KYMA_ENVIRONMENT_BROKER_REPO }}/commits -q '.[0].sha')
echo "Latest commit sha: $COMMIT_SHA"
echo "Bump sha: ${{ needs.bumps.outputs.latest_commit}}"
if [ "$COMMIT_SHA" != "${{ needs.bumps.outputs.latest_commit}}" ]; then
echo "::error ::a PR may have been merged before the tag and draft release were created. Delete the tag and the draft release. Don't rerun this workflow. Create a new release with the same version"
exit 1
fi

outputs:
release_id: ${{ steps.create-draft.outputs.release_id }}

Expand Down
Loading