Closed kimseungbin closed 11 hours ago
The changes in this pull request modify the action.yaml
file for the "Release Automation Action" GitHub Action. A new required input parameter, github-token
, has been added for authentication purposes, while the previously existing input parameter, name
, has been removed. The execution environment and entry point specified in the runs
section remain unchanged. Additionally, a new GitHub Actions workflow file named tag-and-release.yaml
has been introduced, which triggers on issue and pull request events to automate tagging and releasing processes. The README.md
has been updated for clarity, and a new vite.config.ts
file has been added for build configurations.
File | Change Summary |
---|---|
action.yaml | - Added required input parameter github-token for authentication. - Removed input parameter name . - Updated author name to SeungBin Kim . |
.github/workflows/tag-and-release.yaml | - Introduced new workflow for automated tagging and releasing based on issue and PR events. |
README.md | - Added "Tools used" section mentioning Vite and Vitest. - Restructured "Label Checker" section for clarity. |
package.json | - Added new script "package": "vite build" and new development dependency "vite": "^5.4.11" . |
src/main.ts | - Updated run function to be asynchronous, changing return type to Promise<void> . |
vite.config.ts | - Added new configuration file for Vite build settings. |
.coderabbit.yaml | - Added new key poem: false and reformatted path filter. |
src/main.spec.ts | - Updated tests to reflect changes in input handling and error management. |
Objective | Addressed | Explanation |
---|---|---|
Enhance Label Checker to fully meet objectives (Issue #7) | โ | The changes do not address the Label Checker enhancements required. |
action.yaml
may impact how labels are managed in the action.action.yaml
file are related to the automation of the release process using GitHub Actions, which is also a focus of PR #1.action.yaml
file, particularly the input parameters, may relate to the enhancements in label configurations introduced in PR #8, as both involve aspects of GitHub Actions and their configurations.In the land of code where rabbits play,
A new token shines bright, leading the way.
The name has hopped off, but fear not,
For withgithub-token
, new magic is wrought!
Let's celebrate changes, both big and small,
In our GitHub garden, we cherish them all! ๐โจ
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Actionable comments posted: 3
๐งน Outside diff range and nitpick comments (1)
.github/workflows/tag-and-release.yaml (1)>
1-8
: Consider additional architectural improvementsBased on the PR objectives, consider these enhancements:
- Add a configuration file (e.g.,
.github/label-config.yml
) to externalize label definitions- Add error handling and status reporting
- Consider adding a job to sync label configurations across repositories if needed
Would you like assistance in implementing any of these improvements?
๐งฐ Tools
๐ช actionlint 6-6: "steps" section is missing in job "label-check" (syntax-check)
8-8: "steps" section must be sequence node but got scalar node with "!!str" tag (syntax-check)
๐ช yamllint [error] 8-8: no new line character at the end of file (new-line-at-end-of-file)
๐ Review details
@coderabbitai Help me with those enhancements.
[!TIP] For best results, initiate chat on the files or code changes.
@kimseungbin, I'd be happy to help you with these enhancements. Here are the steps to implement them:
1. Add a configuration file to externalize label definitions
Create a file named .github/label-config.yml
in your repository to define your labels. This allows you to manage labels without hardcoding them in your action code.
labels:
- name: bug
color: "d73a4a"
description: "Something isn't working"
- name: enhancement
color: "a2eeef"
description: "New feature or request"
- name: documentation
color: "0075ca"
description: "Improvements or additions to documentation"
# Add more labels as needed
2. Modify your GitHub Action to read from the configuration file
Update your action code to read the labels from the configuration file and create or update them accordingly. Here's an example in JavaScript:
const core = require('@actions/core');
const github = require('@actions/github');
const fs = require('fs');
const yaml = require('js-yaml');
async function run() {
try {
const token = core.getInput('github-token');
const octokit = github.getOctokit(token);
const { owner, repo } = github.context.repo;
// Read label configuration
const configPath = '.github/label-config.yml';
const configFile = fs.readFileSync(configPath, 'utf8');
const config = yaml.load(configFile);
// Iterate over labels and create or update them
for (const label of config.labels) {
try {
// Try to create the label
await octokit.rest.issues.createLabel({
owner,
repo,
name: label.name,
color: label.color,
description: label.description,
});
core.info(`Label '${label.name}' created.`);
} catch (error) {
if (error.status === 422) {
// Label already exists, update it
await octokit.rest.issues.updateLabel({
owner,
repo,
name: label.name,
new_name: label.name,
color: label.color,
description: label.description,
});
core.info(`Label '${label.name}' updated.`);
} else {
throw error;
}
}
}
core.info('All labels have been processed.');
} catch (error) {
core.setFailed(`Action failed with error: ${error.message}`);
}
}
run();
3. Add error handling and status reporting
In the code above, error handling is implemented using try...catch
blocks. If an attempt to create a label fails because it already exists (HTTP status code 422), the code updates the existing label. Any other errors cause the action to fail, and a descriptive error message is provided using core.setFailed
.
4. Fix the syntax errors in your workflow file
The actionlint
errors indicate issues with the steps
section in your workflow file .github/workflows/tag-and-release.yaml
. Here's a corrected version:
name: Tag and Release
on:
issues:
types: [opened, edited]
pull_request:
types: [opened, edited]
jobs:
label-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run Label Checker
uses: kimseungbin/tag-and-release@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Explanation:
steps
section: The steps
section is required within each job. It must be a sequence (list) of steps.actions/checkout@v3
so that the action can access files in your repository (like the label configuration file).with
inputs.5. Ensure your YAML files end with a newline
The yamllint
error indicates that there's no new line character at the end of the file. Make sure to add an empty line at the end of your YAML files to adhere to best practices.
6. Consider adding a job to sync label configurations across repositories
If you manage multiple repositories and want to sync label configurations across them, you can extend your action. Here's an example:
// Add this near the beginning of your run function
const repositories = core.getInput('repositories'); // Comma-separated list of repositories
// Parse the repositories input
const repoList = repositories.split(',').map(repo => repo.trim());
for (const repoName of repoList) {
const [owner, repo] = repoName.split('/');
// Use the existing label processing logic for each repository
for (const label of config.labels) {
try {
await octokit.rest.issues.createLabel({
owner,
repo,
name: label.name,
color: label.color,
description: label.description,
});
core.info(`Label '${label.name}' created in ${owner}/${repo}.`);
} catch (error) {
if (error.status === 422) {
await octokit.rest.issues.updateLabel({
owner,
repo,
name: label.name,
new_name: label.name,
color: label.color,
description: label.description,
});
core.info(`Label '${label.name}' updated in ${owner}/${repo}.`);
} else {
core.warning(`Failed to process label '${label.name}' in ${owner}/${repo}: ${error.message}`);
}
}
}
}
Notes:
Input for repositories: You'll need to add a new input parameter repositories
to your action to specify which repositories to sync.
Update your action.yaml
:
inputs:
github-token:
description: "GitHub token for authentication"
required: true
repositories:
description: "Comma-separated list of repositories to sync labels"
required: false
Permissions: Ensure the provided github-token
has access to all the repositories you wish to update.
7. Update action.yaml
with new inputs
Make sure your action.yaml
file includes all necessary input definitions:
name: "Release Automation Action"
author: "SeungBin Kim"
description: "An action to automate labeling and releases."
inputs:
github-token:
description: "GitHub token for authentication"
required: true
repositories:
description: "Comma-separated list of repositories to sync labels"
required: false
runs:
using: "node16"
main: "dist/index.js"
Let me know if you have any questions or need further assistance implementing these enhancements!
@coderabbitai Update PR title
[!TIP] For best results, initiate chat on the files or code changes.
@kimseungbin, to update the PR title, please click on the "Edit" button (the pencil icon) next to the current title at the top of the pull request page. Then you can modify the title as needed and save your changes.
@coderabbitai Update the PR title according to the changes.
[!TIP] For best results, initiate chat on the files or code changes.
@kimseungbin, based on the changes in this pull request, I suggest updating the title to:
"Enhance Label Checker with External Configuration and Workflow Improvements"
This title reflects the following updates:
.github/label-config.yml
to manage labels externally.tag-and-release.yaml
workflow for label checking on issue and PR events.package.json
with a new build script using Vite.src/main.spec.ts
to cover new functionalities.vite.config.ts
for build configurations.Feel free to adjust the title if needed. Let me know if you need any further assistance!
Summary by CodeRabbit
New Features
github-token
, for enhanced authentication in the Release Automation Action.Bug Fixes
name
input parameter to streamline the action's configuration.Chores
Close #7