update to use team key #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Create Documentation Linear Issue | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| team-key: | ||
| required: true | ||
| description: The key of the team in Linear e.g. ENG, DEV etc. | ||
| secrets: | ||
| linear-api-key: | ||
| required: true | ||
| description: An API key to use to create an issue for documentation. | ||
| linear-label-id: | ||
| required: true | ||
| description: The ID of the label to be added to the issue. | ||
| jobs: | ||
| create-issue: | ||
| if: > | ||
| github.event.pull_request.merged == true && | ||
| contains(github.event.pull_request.labels.*.name, 'docs: needed') | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Create Linear Issue | ||
| env: | ||
| LINEAR_API_KEY: ${{ secrets.linear-api-key }} | ||
| LINEAR_LABEL_ID: ${{ secrets.linear-label-id }} | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| PR_BODY: ${{ github.event.pull_request.body }} | ||
| run: | | ||
| PAYLOAD=$(jq -n \ | ||
| --arg t "${{ inputs.team-key }}: $PR_TITLE" \ | ||
| --arg d "PR: $PR_URL\n\n$PR_BODY" \ | ||
| --arg id "${{ inputs.team-key }}" \ | ||
| --arg l "$LINEAR_LABEL_ID" \ | ||
| '{ | ||
| query: "mutation($t:String!,$d:String!,$id:String!,$l:[String!]){issueCreate(input:{title:$t,description:$d,teamId:$id,labelIds:$l}){success issue{identifier url}}}", | ||
| variables: { t: $t, d: $d, id: $id, l: [$l] } | ||
| }') | ||
| RESPONSE=$(curl -s -X POST https://api.linear.app/graphql \ | ||
| -H "Content-Type: application/json" \ | ||
| -H "Authorization: $LINEAR_API_KEY" \ | ||
| -d "$PAYLOAD") | ||
| echo "$RESPONSE" | jq . | ||