label-action
is a GitHub Action that temporarily creates a label to trigger GitHub Actions workflows using the labels:created
event.
It can be used to implement our Client/Server Model in GitHub Actions, enhancing security.
- Enables implementation of our Client/Server Model
- Requires only
issues:write
permission - Easy to use
About our Client/Server Model, please see the document. Since our Client/Server Model can be applied to many different use cases, it makes sense to create specialized actions for each. However, label creation is a common step across all of them. Rather than implementing it separately in each action, encapsulating it in a shared, standalone action improves maintainability.
That’s why we developed this action.
- uses: actions/create-github-app-token@v2
id: token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
permission-issues: write
owner: ${{ github.repository_owner }}
repositories: |
server-repository
- uses: csm-actions/label-action@main
with:
prefix: update-branch-
description: ${{github.repository}}/${{github.event.number}}
repository: server-repository
github_token: ${{steps.token.outputs.token}}
prefix
: The prefix for the label name. The actual label name will consist of this prefix plus a random string, resulting in a 50-character name. The random string helps avoid label name collisions.
description
: The description of the label. Defaults to an empty string.delete_label
: Whether to delete the label shortly after creation. Defaults to deleting it after 1 second.repository
: The repository name where the label will be created. Please don't specify the repository owner. By default, the repository is the one where the workflow is running.github_token
: The GitHub Access Token used to create the label. The default is a GitHub Actions token. The permissionissues:write
is required
label_name
: The name of the label that was created.