hugo-theme-relearn/.github/actions/check_milestone/action.yaml

111 lines
3.7 KiB
YAML
Raw Normal View History

2021-10-23 09:56:11 +00:00
name: Check milestone
description: Checks if the given milestone and its according tag are valid to be released
inputs:
milestone:
description: Milestone for this release
required: true
github_token:
description: Secret GitHub token
required: true
outputs:
outcome:
description: Result of the check, success or failure
value: ${{ steps.outcome.outputs.outcome }}
runs:
using: composite
steps:
- name: Get closed issues for milestone
id: closed_issues
uses: octokit/graphql-action@v2.x
env:
MILESTONE: ${{ inputs.milestone }}
GITHUB_TOKEN: ${{ inputs.github_token }}
2021-10-23 09:56:11 +00:00
with:
query: |
query {
2024-09-20 19:49:35 +00:00
search(first: 1, type: ISSUE, query: "repo:${{ github.repository_owner }}/${{ github.event.repository.name }} milestone:${{ env.MILESTONE }} state:closed") {
2021-10-23 09:56:11 +00:00
issueCount
}
}
- name: Get open issues for milestone
id: open_issues
uses: octokit/graphql-action@v2.x
env:
MILESTONE: ${{ inputs.milestone }}
GITHUB_TOKEN: ${{ inputs.github_token }}
2021-10-23 09:56:11 +00:00
with:
query: |
query {
2024-09-20 19:49:35 +00:00
search(first: 1, type: ISSUE, query: "repo:${{ github.repository_owner }}/${{ github.event.repository.name }} milestone:${{ env.MILESTONE }} state:open") {
2021-10-23 09:56:11 +00:00
issueCount
}
}
2024-09-20 19:49:35 +00:00
- name: Get current major version number
id: majorvers
uses: azarc-io/regex-property-action@master
env:
MILESTONE: ${{ inputs.milestone }}
2024-09-14 23:23:35 +00:00
with:
2024-09-20 19:49:35 +00:00
value: ${{ env.MILESTONE }}
regex: (\d+)\.\d+\.\d+
replacement: "$1"
2024-09-14 23:23:35 +00:00
2024-09-20 19:49:35 +00:00
- name: Get current minor version number
id: minorvers
uses: azarc-io/regex-property-action@master
env:
MILESTONE: ${{ inputs.milestone }}
with:
2024-09-20 19:49:35 +00:00
value: ${{ env.MILESTONE }}
regex: \d+\.(\d+)\.\d+
replacement: "$1"
- name: Get current patch version number
id: patchvers
2024-09-20 19:49:35 +00:00
uses: azarc-io/regex-property-action@master
2021-10-23 09:56:11 +00:00
env:
MILESTONE: ${{ inputs.milestone }}
with:
value: ${{ env.MILESTONE }}
regex: \d+\.\d+\.(\d+)
replacement: "$1"
2024-09-20 19:49:35 +00:00
- name: Check if releasenotes exists
2024-09-14 23:23:35 +00:00
id: releasenotes
2024-09-20 19:49:35 +00:00
shell: bash
run: |
2024-09-29 21:54:17 +00:00
if [ -f "exampleSite/content/introduction/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}.en.md" ]; then
2024-09-20 19:49:35 +00:00
echo "file_exists=true" >> $GITHUB_OUTPUT
else
echo "file_exists=false" >> $GITHUB_OUTPUT
fi
2021-10-23 09:56:11 +00:00
- name: Set outcome
id: outcome
shell: bash
run: |
2024-09-20 19:49:35 +00:00
if [[ \
${{ fromJSON(steps.closed_issues.outputs.data).search.issueCount }} -gt 0 && \
${{ fromJSON(steps.open_issues.outputs.data).search.issueCount }} -eq 0 && \
${{ steps.releasenotes.outputs.file_exists == 'true' }} \
]]; then
echo "outcome=success" >> $GITHUB_OUTPUT
2021-10-23 09:56:11 +00:00
else
echo "outcome=failure" >> $GITHUB_OUTPUT
2021-10-23 09:56:11 +00:00
fi
- name: Log results and exit
shell: bash
run: |
2024-09-20 19:49:35 +00:00
echo outcome : ${{ steps.outcome.outputs.outcome }}
echo has closed issues : ${{ fromJSON(steps.closed_issues.outputs.data).search.issueCount > 0 }}
echo count : ${{ fromJSON(steps.closed_issues.outputs.data).search.issueCount }}
echo has all issues closed : ${{ fromJSON(steps.open_issues.outputs.data).search.issueCount == 0 }}
echo count : ${{ fromJSON(steps.open_issues.outputs.data).search.issueCount }}
echo has releasenotes : ${{ steps.releasenotes.outputs.file_exists }}
2021-10-23 09:56:11 +00:00
if [ "${{ steps.outcome.outputs.outcome }}" = "failure" ]; then
exit 1
fi