Issue Helper Change Title #6
Workflow file for this run
This file contains 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: 'Issue Helper Change Title' | |
on: | |
workflow_dispatch: | |
inputs: | |
item_id: | |
description: 'The Issue ID' | |
required: true | |
type: number | |
new_title: | |
description: 'The New Issue Title' | |
required: true | |
type: string | |
permissions: | |
issues: write | |
concurrency: | |
group: lock | |
jobs: | |
issue_change_title: | |
name: Issue - Change - Title | |
runs-on: ubuntu-24.04 | |
if: github.actor == 'dakanji' | |
steps: | |
# Generate App Token - https://github.com/actions/create-github-app-token | |
- id: app-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ vars.APP_ID }} | |
private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
# Get/Save Issue Data - GitHub API | |
- id: changetitle_01 | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.PAT_TOKEN }} | |
script: | | |
const issueNumber = context.payload.inputs.item_id; | |
const { data } = await github.rest.issues.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber | |
}); | |
const isLocked = data.locked ? 'true' : 'false'; | |
const fs = require('fs'); | |
fs.appendFileSync(process.env.GITHUB_ENV, `islocked=${isLocked}\n`); | |
# Set NodeJS Up - https://github.com/actions/setup-node | |
- id: changetitle_02 | |
uses: actions/setup-node@v4 | |
with: | |
# Using range for flexibility | |
node-version: '>=20 <22' | |
# Update Issue Title - GitHub API | |
- id: changetitle_03 | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
run: | | |
ISSUE_ID=${{ github.event.inputs.item_id }} | |
NEW_TITLE="${{ github.event.inputs.new_title }}" | |
curl -X PATCH \ | |
-H "Authorization: token ${GITHUB_TOKEN}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/issues/${ISSUE_ID} \ | |
-d "{\"title\": \"${NEW_TITLE}\"}" |