Skip to content

Commit

Permalink
Fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Mar 15, 2024
1 parent 0128b5a commit 5757a43
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
21 changes: 15 additions & 6 deletions .github/actions/rebase-dependency-main-branch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ outputs:
dependency-version:
description: "The version of the dependency as present in the top pom.xml of its main branch"
value: ${{ steps.checkout-dependency.outputs.dependency-version }}
exit-status:
description: |
A short string describing how the execution went.
It can be one of the following:
* success
* rebase-failed
* build-failed
value: ${{ env.REBASE_DEPENDENCY_MAIN_EXIT_STATUS }}

runs:
using: 'composite'
Expand All @@ -42,6 +50,7 @@ runs:
- name: rebase ${{ inputs.dependency-short-name }}-main
shell: bash
run: |
echo "REBASE_DEPENDENCY_MAIN_EXIT_STATUS=success" >> $GITHUB_ENV
git fetch origin main
git reset --hard origin/main
git fetch origin ${{ inputs.dependency-short-name }}-main
Expand All @@ -57,9 +66,10 @@ runs:
if: ${{ failure() }}
shell: bash
run: |
echo "REBASE_DEPENDENCY_MAIN_EXIT_STATUS=rebase-failed" >> $GITHUB_ENV
oldState=$(gh issue view ${{ inputs.issue-id }} --json state -q .state -R ${{ github.repository }})
echo "oldState = $oldState"
msg="Could not rebase ${{ inputs.dependency-short-name }}-main in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
msg="Could not rebase ${{ inputs.dependency-short-name }}-main in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if [[ "$oldState" == "OPEN" ]] ; then
gh issue comment \
--repo ${{ github.repository }} \
Expand All @@ -75,7 +85,6 @@ runs:
GH_TOKEN: ${{ inputs.token }}

- name: Install xmllint
id: checkout-dependency
shell: bash
run: |
sudo apt-get -qq install -y libxml2-utils
Expand All @@ -86,10 +95,10 @@ runs:
run: |
cd ~
[[ -d "${{ inputs.dependency-short-name }}" ]] || git clone --depth 1 --branch main ${{ inputs.dependency-git-repo-url }}
cd "${{ inputs.dependency-short-name }}" \
&& echo "Current ${{ inputs.dependency-short-name }} commit: $(git rev-parse HEAD)" \
&& echo "dependency-commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT \
&& echo "dependency-version=$(xmllint --xpath "/*[local-name() = 'project']/*[local-name() = 'version']/text()" pom.xml)" >> $GITHUB_OUTPUT
cd "${{ inputs.dependency-short-name }}"
echo "Current ${{ inputs.dependency-short-name }} commit: $(git rev-parse HEAD)"
echo "dependency-commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "dependency-version=$(xmllint --xpath "/*[local-name() = 'project']/*[local-name() = 'version']/text()" pom.xml)" >> $GITHUB_OUTPUT
- name: Set ${{ inputs.dependency-short-name }}.version to ${{ steps.checkout-dependency.outputs.dependency-version }}
shell: bash
Expand Down
31 changes: 25 additions & 6 deletions .github/workflows/quarkus-main-rebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,39 @@ jobs:
git push origin ${{ env.DEPENDENCY_SHORT_NAME }}-main -f
- name: Reopen issue https://github.com/${{ github.repository }}/issues/${{ inputs.issue-id }}
if: ${{ failure() }}
if: ${{ steps.rebase-dependency-main-branch.outputs.exit-status != 'success' && failure() }}
shell: bash
run: |
gh issue reopen \
--repo ${{ github.repository }} \
--comment "Build with ${{ env.DEPENDENCY_SHORT_NAME }} ${{ steps.rebase-dependency-main-branch.outputs.dependency-commit }} failed in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
${{ env.ISSUE_ID }}
oldState=$(gh issue view ${{ inputs.issue-id }} --json state -q .state -R ${{ github.repository }})
echo "oldState = $oldState"
msg="❌ Build with ${{ env.DEPENDENCY_SHORT_NAME }} ${{ steps.rebase-dependency-main-branch.outputs.dependency-commit }} failed in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if [[ "$oldState" == "OPEN" ]] ; then
gh issue comment \
--repo ${{ github.repository }} \
--body "$msg" \
${{ inputs.issue-id }}
else
gh issue reopen \
--repo ${{ github.repository }} \
--comment "$msg" \
${{ inputs.issue-id }}
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Close issue https://github.com/${{ github.repository }}/issues/${{ inputs.issue-id }}
if: ${{ success() }}
shell: bash
run: gh issue close --repo ${{ github.repository }} ${{ env.ISSUE_ID }}
run: |
oldState=$(gh issue view ${{ inputs.issue-id }} --json state -q .state -R ${{ github.repository }})
echo "oldState = $oldState"
msg="✅ Build with ${{ env.DEPENDENCY_SHORT_NAME }} ${{ steps.rebase-dependency-main-branch.outputs.dependency-commit }} succeeded in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if [[ "$oldState" != "CLOSED" ]] ; then
gh issue close \
--repo ${{ github.repository }} \
--comment "$msg" \
${{ inputs.issue-id }}
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 5757a43

Please sign in to comment.