Skip to content

Commit

Permalink
add label instead of hello
Browse files Browse the repository at this point in the history
  • Loading branch information
hamid-Ft committed Nov 24, 2023
1 parent 4eea542 commit c94a9fb
Show file tree
Hide file tree
Showing 6 changed files with 405 additions and 998 deletions.
9 changes: 8 additions & 1 deletion .github/action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: 'Label ne PRs'
description: 'add label when new PR opened'
author: 'Hamid-Ft'

inputs:
gh-token:
description: 'The Github token for authentication'
required: true
label:
description: 'the label to be applied to the pull request'
required: true
runs:
using: 'node16'
main: 'index.js'
main: 'index.ts'
1 change: 0 additions & 1 deletion .github/action/index.js

This file was deleted.

29 changes: 29 additions & 0 deletions .github/action/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { getInput, setFailed } from '@actions/core';
import { context, getOctokit } from '@actions/github';

export async function run() {
const token = getInput('gh-token');
const label = getInput('label');

const octokit = getOctokit(token);
const pullRequest = context.payload.pull_request;

try {
if (!pullRequest) {
throw new Error('This action can only be run on Pull Requests');
}

await octokit.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequest.number,
labels: [label],
});
} catch (error) {
setFailed((error as Error)?.message ?? 'Unknown error');
}
}

if (!process.env.JEST_WORKER_ID) {
run();
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: 'Hello'

on:
workflow_dispatch:
pull_request:
types: [opened, reopened]

jobs:
hello:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/action
with:
gh-token: ${{secrets.GITHUB_TOKEN}}
label: 'enhancement'
Loading

0 comments on commit c94a9fb

Please sign in to comment.