Skip to content
Permalink
Browse files

[github] auto milestone, fix increase step, use int

  • Loading branch information
3nids committed Jan 10, 2020
1 parent b4b4338 commit 83951a461d71e9aca96c35c66869a20d7815fb45
Showing with 9 additions and 8 deletions.
  1. +9 −8 .github/workflows/pr-auto-milestone.yml
@@ -65,7 +65,7 @@ jobs:
NUMBER_OF_PRS=$(echo "${PRS_TO_PROCESS}" | jq -s '. | length')
echo "NUMBER_OF_PRS: ${NUMBER_OF_PRS}"
# early exit
[[ ${NUMBER_OF_PRS} == 0 ]] && echo "::set-output name=has_milestone_to_set::false" && exit 0
[[ ${NUMBER_OF_PRS} == 0 ]] && echo "::set-output name=has_milestone_to_set::0" && exit 0
# Take the first
PR_NUMBER=$(echo "${PRS_TO_PROCESS}" | jq -s '. | first')
@@ -87,17 +87,18 @@ jobs:
MAX_RELEASE=$(echo "${JSON_DATA}" | jq ".repository.refs.edges[].node.name | select( . | test(\"^final-${QGIS_MAJOR_VERSION}${MINOR_VERSION}\") ) | sub(\"^final-${QGIS_MAJOR_VERSION}_(?<m>[0-9]+)_(?<p>.)\"; .m+\".\"+.p) | tonumber" | jq -s '. | max')
echo "MAX_RELEASE: ${MAX_RELEASE}"
INCREASE_STEP=$([[ -z ${MINOR_VERSION} ]] && echo "2.0" || echo "0.1" )
MILESTONE_TITLE="${QGIS_MAJOR_VERSION}."$(echo "${MAX_RELEASE} + ${INCREASE_STEP} " | bc)
INCREASE_OPERATION=$([[ -z ${MINOR_VERSION} ]] && echo "${MAX_RELEASE%.*} + 2.0" || echo "${MAX_RELEASE} + 0.1" )
echo "INCREASE_OPERATION: ${INCREASE_OPERATION}"
MILESTONE_TITLE="${QGIS_MAJOR_VERSION}."$(echo "${INCREASE_OPERATION}" | bc)
echo "MILESTONE_TITLE: ${MILESTONE_TITLE}"
MILESTONE_NUMBER=$(echo "${JSON_DATA}" | jq ".repository.milestones.edges[] | select( .node.title == \"${MILESTONE_TITLE}\" ) | .node.number")
echo "MILESTONE_NUMBER: ${MILESTONE_NUMBER}"
HAS_MILESTONE_TO_CREATE=$(echo "${JSON_DATA}" | jq ".repository.milestones.edges[] | select( .node.title == \"${MILESTONE_TITLE}\" ) | length == 0 ")
HAS_MILESTONE_TO_CREATE=$([[ -z ${MILESTONE_NUMBER} ]] && echo "1" || echo "0" )
echo "HAS_MILESTONE_TO_CREATE: ${HAS_MILESTONE_TO_CREATE}"
echo "::set-output name=has_milestone_to_set::true"
echo "::set-output name=has_milestone_to_set::1"
echo "::set-output name=pr_number::${PR_NUMBER}"
echo "::set-output name=milestone_title::${MILESTONE_TITLE}"
echo "::set-output name=milestone_number::${MILESTONE_NUMBER}"
@@ -106,7 +107,7 @@ jobs:
# create the milestone if needed
- name: Create milestone if needed
id: create_milestone
if: steps.extract_data.outputs.has_milestone_to_set == true && steps.extract_data.outputs.has_milestone_to_create == true
if: steps.extract_data.outputs.has_milestone_to_set == 1 && steps.extract_data.outputs.has_milestone_to_create == 1
uses: octokit/request-action@v2.x
with:
route: POST /repos/qgis/QGIS/milestones
@@ -117,7 +118,7 @@ jobs:
# Compute the milestone number
- name: Compute milestone number from existing or created
id: compute_milestone
if: always() == true && steps.extract_data.outputs.has_milestone_to_set == true
if: always() && steps.extract_data.outputs.has_milestone_to_set == 1
env:
MILESTONE_NUMBER_EXISTING: ${{ steps.calculate_milestone.outputs.milestone_number }}
MILESTONE_NUMBER_CREATED_JSON: ${{ steps.create_milestone.outputs.data }}
@@ -128,7 +129,7 @@ jobs:
# update PR with milestone
- name: update PR milestone
if: steps.extract_data.outputs.has_milestone_to_set == true
if: steps.extract_data.outputs.has_milestone_to_set == 1
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 83951a4

Please sign in to comment.
You can’t perform that action at this time.