Sha256: 33d644e6d8ec494169e43cbefcd6ea7c28cc109686051b93069483a02814f71d

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

name: 'Issue sync with Jira'
on:
  issues:
    types: [opened]

permissions:
  issues: write
  contents: read

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - name: Create ticket
        uses: actions/github-script@v7
        with:
          script: |
            const action = context.payload.action;
            if (action !== 'opened') {
              return;
            }
            const title = context.payload.issue.title;
            const body = context.payload.issue.body;

            const res = await fetch('https://algolia.atlassian.net/rest/api/2/issue', {
              method: 'POST',
              headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
                'Authorization': `Basic ${{ secrets.JIRA_TOKEN }}`
              },
              body: JSON.stringify({
                fields: {
                  description: `Issue created by ${context.actor} at [${context.payload.issue.html_url}](${context.payload.issue.html_url}) \n\n${body}`,
                  issuetype: {
                    id: '10001'
                  },
                  parent: {
                    key: 'DI-2737'
                  },
                  project: {
                    id: '10118'
                  },
                  summary: `[GH-ISSUE] ${title}`
                },
                update: {}
              })
            });

            if (!res.ok) {
              throw new Error(`Failed to create ticket: ${res.statusText} (${res.status}) - ${await res.text()}`);
            }

            const data = await res.json();
            console.log(`Created ticket: ${data.key}`);

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
algolia-3.2.4 .github/workflows/issue.yml
algolia-3.2.3 .github/workflows/issue.yml
algolia-3.2.2 .github/workflows/issue.yml
algolia-3.2.1 .github/workflows/issue.yml
algolia-3.2.0 .github/workflows/issue.yml