From 7817ba9a22a1aa17317447a8b9f08d53e6b602dc Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Tue, 21 Jun 2022 15:45:23 +0200 Subject: [PATCH] Create issues.yml --- .github/workflows/issues.yml | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/issues.yml diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml new file mode 100644 index 0000000..3683494 --- /dev/null +++ b/.github/workflows/issues.yml @@ -0,0 +1,57 @@ +name: Issues + +on: [issues] + +jobs: + update: + name: Update Issue + runs-on: ubuntu-latest + steps: + - name: Dump Github Context + run: | + echo '${{ toJSON(github) }}' + echo "update=false" >> $GITHUB_ENV + + if [ ${{ github.event_name }} != "issues" ]; then + echo "This action only operates on issues" + exit 0 + fi + + echo "update=true" >> $GITHUB_ENV + - name: Determine action + run: | + if [ ${{ github.event.action }} == "opened" ]; then + echo "action=open" >> $GITHUB_ENV + fi + if [ ${{ github.event.action }} == "reopened" ]; then + echo "action=reopen" >> $GITHUB_ENV + fi + if [ ${{ github.event.action }} == "closed" ]; then + echo "action=close" >> $GITHUB_ENV + fi + - name: Determine type + run: | + if ${{ contains(github.event.*.labels.*.name, 'Type: Bug') }}; then + echo "type=bug" >> $GITHUB_ENV + else + echo "type=story" >> $GITHUB_ENV + fi + - name: Update + if: ${{ env.update == 'true' }} + run: | + id="${{ github.event.issue.html_url }}" + title="${{ github.event.issue.title }}" + component="nrpe_exporter" + + description="Opened by ${{ github.event.issue.user.login }}." + + data=$(jq -n \ + --arg id "$id" \ + --arg action "${{ env.action }}" \ + --arg title "$title" \ + --arg description "$description" \ + --arg component "$component" \ + --arg type "${{ env.type }}" \ + '{data: {id: $id, action: $action, title: $title, description: $description, component: $component, type: $type}}') + + curl -X POST -H 'Content-type: application/json' --data "${data}" "${{ secrets.JIRA_URL }}"