Skip to content

Commit

Permalink
More tests for autolabel
Browse files Browse the repository at this point in the history
  • Loading branch information
DelazJ committed Jun 19, 2023
1 parent f971ff2 commit 8fdc2df
Showing 1 changed file with 73 additions and 2 deletions.
75 changes: 73 additions & 2 deletions .github/workflows/auto-label.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Set Issue Label for issues from main QGIS repo"
on:
issues:
types: [opened]
types: [opened, reopened, closed]

permissions:
contents: read
Expand All @@ -13,7 +13,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BODY: "${{ github.event.issue.body }}"
MILESTONE: 17 # See https://api.github.com/repos/qgis/QGIS-Documentation/milestones
MILESTONE: 2 # See https://api.github.com/repos/DelazJ/QGIS-Documentation/milestones
runs-on: ubuntu-latest
steps:
- name: Harden Runner
Expand Down Expand Up @@ -45,6 +45,77 @@ jobs:
labels: ["${{ steps.find_version_label.outputs.label }}"]
})
- id: find_pr_labels
name: Find original PR labels
run: |
PR_LABELS=$(echo "${{ env.BODY }}" | sed -n -r "s/.*LABELS: (.*)$/\1/p" | sed 's/\r$//')
echo "prlabels: ${PR_LABELS}"
PR_LABELS3=$(echo ${PR_LABELS} | jq -Rc 'split(", ")')
echo "prlabels3: ${PR_LABELS3}"
if [[ -n "${PR_LABELS}" ]]; then
echo "pr_labels={"LABS":${PR_LABELS3}}" >> $GITHUB_OUTPUT
else
echo "no useful labels found in the report"
fi
# PR_LABELS2=[$(echo "${PR_LABELS}" | sed "s/.*LABELS: (.*)$/\"\1\"/p")]
# echo "prlabels2: ${PR_LABELS2}"
# PR_LABELS=[$(echo "${{ env.BODY }}" | sed -n -r "s/.*LABELS: (.*)/\"\1\"/p" | sed 's/, /\", \"/g')]
# echo 'toto: ["'"${${PR_LABELS}//,/'"','"'}"'"]'

- id: apply_pr_labels
if: ${{ steps.find_pr_labels.outputs.pr_labels }}
env:
PR: ${{ fromJSON( steps.find_pr_labels.outputs.pr_labels ) }}
name: Apply PR labels
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ${{ env.PR.LABS }}
})
# }
# ${{ fromJSON( steps.find_pr_labels.outputs.pr_labels ) }}
# echo "mylabels : ${{ steps.find_pr_labels.outputs.pr_labels }}"
# echo "::set-output name=matrix-browser::[\"${testBro//', '/\",\"}\"]"
# for (const label of ${{ steps.find_pr_labels.outputs.pr_labels }}) {

- id: set-result
uses: actions/github-script@v6
with:
script: return "Hello!"
result-encoding: string
- name: Get result
run: echo "${{steps.set-result.outputs.result}}"


- id: get_pr_labels
name: Report PR labels
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
result-encoding: string
script: |
const LABOS = github.rest.issues.listLabelsOnIssue({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
echo "labos: ${LABOS}"
echo "labos=${LABOS}" >> $GITHUB_OUTPUT
- name: resultat
run: echo "${{steps.get_pr_labels.outputs.result}}"
shell: bash

- name: eventer
run: |
LABS=$(join(${{ github.event.issue.labels.*.name }}, ', '))
echo "labs: ${LABS}"
echo "labs=${LABS}" >> $GITHUB_OUTPUT
- id: assign_milestone
name: Assign milestone
if: ${{ steps.find_version_label.outputs.label }}
Expand Down

0 comments on commit 8fdc2df

Please sign in to comment.