Compare commits

..

No commits in common. "main" and "v2" have entirely different histories.
main ... v2

15 changed files with 108 additions and 2407 deletions

View File

@ -1,44 +0,0 @@
{
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"contributors": [
{
"login": "loarca",
"name": "Alejandro Loarca",
"avatar_url": "https://avatars.githubusercontent.com/u/22898638?v=4",
"profile": "https://github.com/loarca",
"contributions": [
"code"
]
},
{
"login": "IanWoodard",
"name": "Ian Woodard",
"avatar_url": "https://avatars.githubusercontent.com/u/17186604?v=4",
"profile": "https://ianwoodard.me",
"contributions": [
"doc"
]
},
{
"login": "boidolr",
"name": "Raphael Boidol",
"avatar_url": "https://avatars.githubusercontent.com/u/652404?v=4",
"profile": "https://home.boidol.dev/",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
"projectName": "branch-names",
"projectOwner": "tj-actions",
"repoType": "github",
"repoHost": "https://github.com",
"skipCi": true,
"commitType": "docs",
"commitConvention": "angular"
}

10
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,10 @@
* branch-name:
### Description
Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.
### What I Did
Add some details about your workflow ?

View File

@ -1,9 +0,0 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
labels:
- "merge when passing"

View File

@ -1,56 +0,0 @@
# This workflow checks out code, performs a Codacy security scan
# and integrates the results with the
# GitHub Advanced Security code scanning feature. For more information on
# the Codacy security scan action usage and parameters, see
# https://github.com/codacy/codacy-analysis-cli-action.
# For more information on Codacy Analysis CLI in general, see
# https://github.com/codacy/codacy-analysis-cli.
name: Codacy Security Scan
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '15 16 * * 2'
jobs:
codacy-security-scan:
# Cancel other workflows that are running for the same branch
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
continue-on-error: true
uses: codacy/codacy-analysis-cli-action@v4.4.5
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will hand over control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
continue-on-error: true
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif

View File

@ -1,18 +0,0 @@
name: Automatic Rebase
on:
issue_comment:
types: [created]
jobs:
rebase:
name: Rebase
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ secrets.PAT_TOKEN }}
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.8
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}

View File

@ -1,35 +0,0 @@
name: Update release version.
on:
release:
types: [published]
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Run release-tagger
uses: tj-actions/release-tagger@v4
- name: Sync release version.
uses: tj-actions/sync-release-version@v13
id: sync-release-version
with:
pattern: '${{ github.repository }}@'
only_major: true
paths: |
README.md
- name: Run git-cliff
uses: tj-actions/git-cliff@v1
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
base: "main"
labels: "merge when passing"
title: "Upgraded to ${{ steps.sync-release-version.outputs.new_version }}"
branch: "upgrade-to-${{ steps.sync-release-version.outputs.new_version }}"
commit-message: "Upgraded from ${{ steps.sync-release-version.outputs.old_version }} -> ${{ steps.sync-release-version.outputs.new_version }}"
body: "View [CHANGES](https://github.com/${{ github.repository }}/compare/${{ steps.sync-release-version.outputs.old_version }}...${{ steps.sync-release-version.outputs.new_version }})"
token: ${{ secrets.PAT_TOKEN }}

View File

@ -2,87 +2,39 @@ name: CI
on:
push:
tags:
- '*'
branches:
- main
release:
types: [published, created]
pull_request:
branches:
- main
jobs:
test:
name: Test branch-names
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ubuntu-latest
name: Test branch-name
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
uses: actions/checkout@v2
- name: Run test
id: branch-names
id: branch-name
uses: ./
- name: Show output
run: |
echo "Default Branch: ${{ steps.branch-names.outputs.default_branch }}"
echo "Current Branch: ${{ steps.branch-names.outputs.current_branch }}"
echo "Base Ref: ${{ steps.branch-names.outputs.base_ref_branch }}"
echo "Head Ref: ${{ steps.branch-names.outputs.head_ref_branch }}"
echo "Ref: ${{ steps.branch-names.outputs.ref_branch }}"
echo "Is Default: ${{ steps.branch-names.outputs.is_default }}"
echo "Is Tag: ${{ steps.branch-names.outputs.is_tag }}"
echo "Current tag: ${{ steps.branch-names.outputs.tag }}"
- name: Test is_default output for pull request
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && steps.branch-names.outputs.is_default != 'false'
echo "${{ steps.branch-name.outputs.base_ref_branch }}"
echo "${{ steps.branch-name.outputs.head_ref_branch }}"
echo "${{ steps.branch-name.outputs.ref_branch }}"
- name: Test base ref output
if: github.event_name == 'pull_request' && !steps.branch-name.outputs.base_ref_branch
run: |
echo "Is default is invalid: ${{ steps.branch-names.outputs.is_default }}"
echo "Base ref unset: ${{ steps.branch-name.outputs.base_ref_branch }}"
exit 1
- name: Test is_default output for non pull request
if: "!contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && steps.branch-names.outputs.is_default != 'true'"
- name: Test head ref output
if: github.event_name == 'pull_request' && !steps.branch-name.outputs.head_ref_branch
run: |
echo "Is default is invalid: ${{ steps.branch-names.outputs.is_default }}"
echo "Head ref unset: ${{ steps.branch-name.outputs.head_ref_branch }}"
exit 1
- name: Test base_ref_branch output
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.base_ref_branch
- name: Test ref output
if: "!steps.branch-name.outputs.ref_branch"
run: |
echo "Base ref unset: ${{ steps.branch-names.outputs.base_ref_branch }}"
exit 1
- name: Test head_ref output
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.head_ref_branch
run: |
echo "Head ref unset: ${{ steps.branch-names.outputs.head_ref_branch }}"
exit 1
- name: Test ref_branch output
if: "!steps.branch-names.outputs.ref_branch && steps.branch-names.outputs.is_tag == 'false'"
run: |
echo "Ref unset: ${{ steps.branch-names.outputs.ref_branch }}"
exit 1
- name: Test current_branch output for pull_request or pull_request_target event.
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.current_branch
run: |
echo "Current branch unset: ${{ steps.branch-names.outputs.current_branch }}"
exit 1
- name: Test current_branch output for push event.
if: github.event_name == 'push' && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.current_branch
run: |
echo "Current branch unset: ${{ steps.branch-names.outputs.current_branch }}"
exit 1
- name: Test current_branch output for tag based push event.
if: github.event_name == 'push' && steps.branch-names.outputs.is_tag == 'true' && !steps.branch-names.outputs.base_ref_branch
run: |
echo "Base ref unset: ${{ steps.branch-names.outputs.base_ref_branch }}"
exit 1
- name: Test tag output for tag based push event.
if: github.event_name == 'push' && steps.branch-names.outputs.is_tag == 'true' && !steps.branch-names.outputs.tag
run: |
echo "Current tag unset: ${{ steps.branch-names.outputs.tag }}"
echo "Ref unset: ${{ steps.branch-name.outputs.ref_branch }}"
exit 1

View File

@ -1,48 +0,0 @@
name: Format README.md
on:
push:
branches:
- main
jobs:
sync-assets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Run auto-doc
uses: tj-actions/auto-doc@v3
with:
use_code_blocks: true
use_major_version: true
- name: Run remark
uses: tj-actions/remark@v3
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v20
id: verify_changed_files
with:
files: |
README.md
- name: README.md changed
if: steps.verify_changed_files.outputs.files_changed == 'true'
run: |
echo "README.md has uncommitted changes"
exit 1
- name: Create Pull Request
if: failure()
uses: peter-evans/create-pull-request@v7
with:
base: "main"
labels: "merge when passing"
title: "Updated README.md"
branch: "chore/update-readme"
commit-message: "Updated README.md"
body: "Updated README.md"
token: ${{ secrets.PAT_TOKEN }}

View File

@ -1,12 +0,0 @@
{
"scanSettings": {
"baseBranches": []
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure",
"displayMode": "diff"
},
"issueSettings": {
"minSeverityLevel": "LOW"
}
}

View File

@ -1,128 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
jtonye@ymail.com.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.

1534
HISTORY.md

File diff suppressed because it is too large Load Diff

324
README.md
View File

@ -1,256 +1,35 @@
## branch-names
branch-names
------------
[![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge\&logo=ubuntu\&logoColor=white)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
[![Mac OS](https://img.shields.io/badge/mac%20os-000000?style=for-the-badge\&logo=macos\&logoColor=F0F0F0)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
[![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge\&logo=windows\&logoColor=white)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
[![Public workflows that use this action.](https://img.shields.io/endpoint?style=for-the-badge\&url=https%3A%2F%2Fused-by.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Dtj-actions%2Fbranch-names%26badge%3Dtrue%26package_id%3DUGFja2FnZS0yOTQyNTYxMTIz)](https://github.com/search?o=desc\&q=tj-actions+branch-names+language%3AYAML\&s=\&type=Code)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4df2ae51586b43f1bfd26e1aedc69965)](https://app.codacy.com/gh/tj-actions/branch-names/dashboard?utm_source=gh\&utm_medium=referral\&utm_content=\&utm_campaign=Badge_grade)
[![CI](https://github.com/tj-actions/branch-names/workflows/CI/badge.svg)](https://github.com/tj-actions/branch-names/actions?query=workflow%3ACI)
[![Update release version.](https://github.com/tj-actions/branch-names/actions/workflows/sync-release-version.yml/badge.svg)](https://github.com/tj-actions/branch-names/actions/workflows/sync-release-version.yml)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
Get a branch or tag name without the `/ref/*` prefix.
## Table of Contents
* [Features](#features)
* [Usage](#usage)
* [Inputs](#inputs)
* [Outputs](#outputs)
* [Events](#events)
* [`push*`](#push)
* [`pull_request*`](#pull_request)
* [`tag*`](#tag)
* [Other supported events](#other-supported-events)
* [Possible usage with actions/checkout](#possible-usage-with-actionscheckout)
* [Credits](#credits)
* [Report Bugs](#report-bugs)
* [Contributors ✨](#contributors-)
## Features
* Retrieve the current branch name without any prefix. (e.g. `'refs/heads/main'` -> `'main'`)
* Retrieve the current tag with an option to strip the prefix (e.g. `v0.0.1` -> `v` -> `0.0.1`)
* Detect actions triggered by non default branches
* Detect actions triggered by the default branch
* Supports all valid [git branch names](https://wincent.com/wiki/Legal_Git_branch_names)
## Usage
Get branch information without the `/ref/*` prefix
```yaml
...
steps:
- name: Get branch names.
id: branch-names
uses: tj-actions/branch-names@v8
- name: Running on the default branch.
if: steps.branch-names.outputs.is_default == 'true'
run: |
echo "Running on default: ${{ steps.branch-names.outputs.current_branch }}"
# Outputs: "Running on default: main"
- name: Running on a pull request branch.
if: steps.branch-names.outputs.is_default == 'false'
run: |
echo "Running on pr: ${{ steps.branch-names.outputs.current_branch }}"
# Outputs: "Running on pr: feature/test"
- name: Running on a pull request branch.
if: steps.branch-names.outputs.is_default == 'false'
run: |
echo "Base branch: ${{ steps.branch-names.outputs.base_ref_branch }}"
# Outputs: "Base branch: main"
- name: Running on any event.
run: |
echo "Default branch: ${{ steps.branch-names.outputs.default_branch }}"
# Outputs: "Default branch: main"
```
If you feel generous and want to show some extra appreciation:
Support this project with a :star:
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
[buymeacoffee]: https://www.buymeacoffee.com/jackton1
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png
## Inputs
<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->
```yaml
- uses: tj-actions/branch-names@v8
id: branch-names
with:
# The prefix that should be
# stripped from the tag e.g
# `v` -> with a tag
# `v0.0.1` -> returns `0.0.1`
# Type: string
strip_tag_prefix: ''
```
<!-- AUTO-DOC-INPUT:END -->
## Outputs
<!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section -->
| OUTPUT | TYPE | DESCRIPTION |
|---------------------------------------------------------------------------------|--------|----------------------------------------------------------------------------------|
| <a name="output_base_ref_branch"></a>[base\_ref\_branch](#output_base_ref_branch) | string | The target branch of a <br>pull request or tag e.g <br>`main` |
| <a name="output_current_branch"></a>[current\_branch](#output_current_branch) | string | The current branch name regardless <br>of event\_type e.g `main`, `feature/test` |
| <a name="output_default_branch"></a>[default\_branch](#output_default_branch) | string | The default branch name e.g <br>`main` OR `master` |
| <a name="output_head_ref_branch"></a>[head\_ref\_branch](#output_head_ref_branch) | string | The source branch of a <br>pull request e.g `feature/test` |
| <a name="output_is_default"></a>[is\_default](#output_is_default) | string | Returns `"true"` if the current <br>branch is the default else <br>`"false"`. |
| <a name="output_is_tag"></a>[is\_tag](#output_is_tag) | string | Returns `"true"` if the current <br>branch is a tag else <br>`"false"`. |
| <a name="output_ref_branch"></a>[ref\_branch](#output_ref_branch) | string | The branch that triggered the <br>workflow run. e.g `1/merge`, `main` |
| <a name="output_tag"></a>[tag](#output_tag) | string | The tag that triggered the <br>workflow run. e.g `v0.0.1`, `0.0.1` |
<!-- AUTO-DOC-OUTPUT:END -->
## Events
### `push*`
```yaml
on:
push:
branches:
- main
...
steps:
- uses: actions/checkout@v2
- name: Get branch names
uses: tj-actions/branch-names@v1
id: branch-names
uses: tj-actions/branch-names@v8
- name: Current branch names
run: |
echo "${{ steps.branch-names.outputs.current_branch }}"
# Outputs: "main" the branch that triggered the push event.
- name: Running on the default branch.
if: steps.branch-names.outputs.is_default == 'true'
run: |
echo "Running on default: ${{ steps.branch-names.outputs.current_branch }}"
# Outputs: "Running on default: main".
- name: Running on the default branch (i.e non tag based branch).
if: steps.branch-names.outputs.is_tag == 'false' && steps.branch-names.outputs.is_default == 'true'
run: |
echo "Running on branch: ${{ steps.branch-names.outputs.current_branch }}"
# Outputs: "Running on branch: main".
- name: Get Ref brach name
run: |
echo "${{ steps.branch-names.outputs.ref_branch }}"
# Outputs: "main"
- name: Default branch name
echo "${{ steps.branch-name.outputs.ref_branch }}"
# Outputs: "main" for non PR branches | "1/merge" for a PR branch
- name: Get Head Ref branch name
if: github.event_name == 'pull_request'
run: |
echo "${{ steps.branch-names.outputs.default_branch }}"
# Outputs: "main" the default branch.
```
### `pull_request*`
```yaml
on:
pull_request:
branches:
- main
...
steps:
- name: Get branch names
id: branch-names
uses: tj-actions/branch-names@v8
- name: Current branch names
run: |
echo "${{ steps.branch-names.outputs.current_branch }}"
echo "${{ steps.branch-name.outputs.head_ref_branch }}"
# Outputs: "feature/test" current PR branch.
- name: Running on a non tag based branch and a PR branch.
if: steps.branch-names.outputs.is_default == 'false'
- name: Get Base Ref branch name
if: github.event_name == 'pull_request'
run: |
echo "Running on branch: ${{ steps.branch-names.outputs.current_branch }}"
# Outputs: "Running on branch: feature/test".
- name: Running on a pull request (i.e non tag based branch).
if: steps.branch-names.outputs.is_tag == 'false' && steps.branch-names.outputs.is_default == 'false'
run: |
echo "Running on branch: ${{ steps.branch-names.outputs.current_branch }}"
# Outputs: "Running on branch: feature/test".
- name: Get Ref branch name
run: |
echo "${{ steps.branch-names.outputs.ref_branch }}"
# Outputs: "1/merge"
- name: Get Head Ref branch names (i.e The current pull request branch)
run: |
echo "${{ steps.branch-names.outputs.head_ref_branch }}"
# Outputs: "feature/test" current PR branch.
- name: Get Base Ref branch names (i.e The target of a pull request.)
run: |
echo "${{ steps.branch-names.outputs.base_ref_branch }}"
# Outputs: "main".
- name: Default branch names
run: |
echo "${{ steps.branch-names.outputs.default_branch }}"
# Outputs: "main" the default branch.
echo "${{ steps.branch-name.outputs.base_ref_branch }}"
# Outputs: "main" for main <- PR branch.
```
### `tag*`
```yaml
on:
push:
tags:
- '*'
...
steps:
- name: Get branch names
id: branch-names
uses: tj-actions/branch-names@v8
with:
strip_tag_prefix: v # Optionally strip the leading `v` from the tag.
- name: Running on a tag branch.
if: steps.branch-names.outputs.is_tag == 'true'
run: |
echo "Running on: ${{ steps.branch-names.outputs.tag }}"
# Outputs: "Running on: 0.0.1".
- name: Get the current tag
if: steps.branch-names.outputs.is_tag == 'true' # Replaces: startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ steps.branch-names.outputs.tag }}"
# Outputs: "0.0.1"
```
### Other supported events
See [.github/workflows/test.yml](https://github.com/tj-actions/branch-names/blob/main/.github/workflows/test.yml) for more examples.
### Possible usage with [actions/checkout](https://github.com/actions/checkout)
### Possible usage with [actions/checkout@v2](https://github.com/actions/checkout):
```yaml
on:
@ -264,52 +43,49 @@ on:
steps:
- name: Get branch names.
id: branch-names
uses: tj-actions/branch-names@v8
- uses: actions/checkout@v4
uses: tj-actions/branch-names@v1
- uses: actions/checkout@v2
with:
ref: ${{ steps.branch-names.outputs.head_ref_branch }}
ref: ${{ steps.branch-names.outputs.base_ref_branch }}
```
* Free software: [MIT license](LICENSE)
## Credits
## Inputs
| Input | type | required | default |
|:-------------:|:-----------:|:-------------:|:---------------------:|
| token | `string` | `false` | `${{ github.token }}` |
## Outputs
| Output | type | Example | Description |
|:--------------------:|:-----------:|:---------------------:|:------------------------------------------------:|
| base_ref_branch | `string` | `main` | The target branch of a pull request |
| head_ref_branch | `string` | `feature/test` | The source branch of a pull request |
| ref_branch | `string` | `1/merge` | `main` | The branch that triggered the workflow run |
* Free software: [MIT license](LICENSE)
Credits
-------
This package was created with [Cookiecutter](https://github.com/cookiecutter/cookiecutter).
## Report Bugs
Report Bugs
-----------
Report bugs at https://github.com/tj-actions/branch-names/issues.
If you are reporting a bug, please include:
* Your operating system name and version.
* Any details about your workflow that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/loarca"><img src="https://avatars.githubusercontent.com/u/22898638?v=4?s=100" width="100px;" alt="Alejandro Loarca"/><br /><sub><b>Alejandro Loarca</b></sub></a><br /><a href="https://github.com/tj-actions/branch-names/commits?author=loarca" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://ianwoodard.me"><img src="https://avatars.githubusercontent.com/u/17186604?v=4?s=100" width="100px;" alt="Ian Woodard"/><br /><sub><b>Ian Woodard</b></sub></a><br /><a href="https://github.com/tj-actions/branch-names/commits?author=IanWoodard" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://home.boidol.dev/"><img src="https://avatars.githubusercontent.com/u/652404?v=4?s=100" width="100px;" alt="Raphael Boidol"/><br /><sub><b>Raphael Boidol</b></sub></a><br /><a href="https://github.com/tj-actions/branch-names/commits?author=boidolr" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
* Your operating system name and version.
* Any details about your workflow that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

View File

@ -1,32 +0,0 @@
# Security Policy
## Proactive Security Measures
To proactively detect and address security vulnerabilities, we utilize several robust tools and processes:
- **Dependency Updates:** We use [Renovate](https://renovatebot.com) and [Dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates) to keep our dependencies updated and promptly patch detected vulnerabilities through automated PRs.
- **[GitHub's Security Features](https://github.com/features/security):** Our repository and dependencies are continuously monitored via GitHub's security features, which include:
- **Code Scanning:** Using GitHub's CodeQL, all pull requests are scanned to identify potential vulnerabilities in our source code.
- **Automated Alerts:** Dependabot identifies vulnerabilities based on the GitHub Advisory Database and opens PRs with patches, while automated [secret scanning](https://docs.github.com/en/enterprise-cloud@latest/code-security/secret-scanning/about-secret-scanning#about-secret-scanning-for-partner-patterns) provides alerts for detected secrets.
- **[GitGuardian Security Checks](https://www.gitguardian.com/):** We employ GitGuardian to ensure security checks are performed on the codebase, enhancing the overall security of our project.
- **Code Analysis and Security Scanning:** With the help of [Codacy Static Code Analysis](https://www.codacy.com/) and [Codacy Security Scan](https://security.codacy.com/), we conduct thorough analyses and scans of our code for potential security risks.
## Reporting Security Vulnerabilities
Despite our best efforts to deliver secure software, we acknowledge the invaluable role of the community in identifying security breaches.
### Private Vulnerability Disclosures
We request all suspected vulnerabilities to be responsibly and privately disclosed by sending an email to [support@tj-actions.online](mailto:support@tj-actions.online).
### Public Vulnerability Disclosures
For publicly disclosed security vulnerabilities, please **IMMEDIATELY** email [support@tj-actions.online](mailto:support@tj-actions.online) with the details for prompt action.
Upon confirmation of a breach, reporters will receive full credit and recognition for their contribution. Please note, that we do not offer monetary compensation for reporting vulnerabilities.
## Communication of Security Breaches
We will utilize the [GitHub Security Advisory](https://github.com/tj-actions/branch-names/security/advisories) to communicate any security breaches. The advisory will be made public once a patch has been released to rectify the issue.
We appreciate your cooperation and contribution to maintaining the security of our software. Remember, a secure community is a strong community.

View File

@ -1,121 +1,48 @@
name: Branch Names
description: Retrieve github branch or tag information without the /ref/* prefix
name: branch-names
description: Retrieve giithub branch information without `/ref/heads` prefix
author: tj-actions
inputs:
strip_tag_prefix:
description: 'The prefix that should be stripped from the tag e.g `v` -> with a tag `v0.0.1` -> returns `0.0.1`'
default: ''
token:
description: 'GITHUB_TOKEN or a Repo scoped PAT'
required: true
default: ${{ github.token }}
base_ref:
description: 'The target branch of a pull request'
default: ${{ github.base_ref }}
required: false
head_ref:
description: 'The source branch of a pull request'
default: ${{ github.head_ref }}
required: false
ref:
description: 'The branch that triggered the workflow run.'
default: ${{ github.ref }}
required: false
outputs:
is_default:
value: ${{ steps.default.outputs.is_default }}
description: 'Returns `"true"` if the current branch is the default else `"false"`.'
is_tag:
value: ${{ steps.tag.outputs.is_tag }}
description: 'Returns `"true"` if the current branch is a tag else `"false"`.'
default_branch:
value: ${{ steps.default.outputs.default_branch }}
description: 'The default branch name e.g `main` OR `master`'
current_branch:
value: ${{ steps.current_branch.outputs.current_branch }}
description: 'The current branch name regardless of event_type e.g `main`, `feature/test`'
base_ref_branch:
value: ${{ steps.branch.outputs.base_ref_branch }}
description: 'The target branch of a pull request or tag e.g `main`'
description: 'The target branch of a pull request'
head_ref_branch:
value: ${{ steps.branch.outputs.head_ref_branch }}
description: 'The source branch of a pull request e.g `feature/test`'
description: 'The source branch of a pull request'
ref_branch:
value: ${{ steps.branch.outputs.ref_branch }}
description: 'The branch that triggered the workflow run. e.g `1/merge`, `main`'
tag:
value: ${{ steps.tag.outputs.tag }}
description: 'The tag that triggered the workflow run. e.g `v0.0.1`, `0.0.1`'
description: 'The branch that triggered the workflow run.'
runs:
using: "composite"
steps:
- id: branch
env:
GITHUB_REF: ${{ github.ref }}
GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref || github.base_ref }}
GITHUB_HEAD_REF: ${{ github.event.pull_request.head.ref || github.head_ref }}
GITHUB_EVENT_BASE_REF: ${{ github.event.base_ref }}
INPUTS_STRIP_TAG_PREFIX: ${{ inputs.strip_tag_prefix }}
run: |
# "Set branch names..."
if [[ "$GITHUB_REF" != "refs/tags/"* ]]; then
BASE_REF=$(printf "%q" "$GITHUB_BASE_REF")
HEAD_REF=$(printf "%q" "$GITHUB_HEAD_REF")
REF=$(printf "%q" "$GITHUB_REF")
BASE_REF=${BASE_REF/refs\/heads\//}
HEAD_REF=${HEAD_REF/refs\/heads\//}
REF_BRANCH=${REF/refs\/pull\//}
REF_BRANCH=${REF_BRANCH/refs\/heads\//}
echo "base_ref_branch=$(eval printf "%s" "$BASE_REF")" >> "$GITHUB_OUTPUT"
echo "head_ref_branch=$(eval printf "%s" "$HEAD_REF")" >> "$GITHUB_OUTPUT"
echo "ref_branch=$(eval printf "%s" "$REF_BRANCH")" >> "$GITHUB_OUTPUT"
else
BASE_REF=$(printf "%q" "$GITHUB_EVENT_BASE_REF")
BASE_REF=${BASE_REF/refs\/heads\/$INPUTS_STRIP_TAG_PREFIX/}
echo "base_ref_branch=$(eval printf "%s" "$BASE_REF")" >> "$GITHUB_OUTPUT"
fi
export BASE_REF=${{ inputs.base_ref }}
export HEAD_REF=${{ inputs.head_ref }}
export REF=${{ inputs.ref }}
echo "::set-output name=base_ref_branch::${BASE_REF/refs\/heads\//}"
echo "::set-output name=head_ref_branch::${HEAD_REF/refs\/heads\//}"
REF_BRANCH=${REF/refs\/pull\//}
echo "::set-output name=ref_branch::${REF_BRANCH/refs\/heads\//}"
shell: bash
- id: current_branch
env:
GITHUB_REF: ${{ github.ref }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
HEAD_REF_BRANCH: ${{ steps.branch.outputs.head_ref_branch }}
REF_BRANCH: ${{ steps.branch.outputs.ref_branch }}
run: |
# "Set the current branch name..."
if [[ "$GITHUB_REF" != "refs/tags/"* ]]; then
if [[ "$GITHUB_EVENT_NAME" == *"pull_request"* ]]; then
echo "current_branch=$HEAD_REF_BRANCH" >> "$GITHUB_OUTPUT"
else
echo "current_branch=$REF_BRANCH" >> "$GITHUB_OUTPUT"
fi
fi
shell: bash
- id: default
env:
GITHUB_REF: ${{ github.ref }}
CURRENT_BRANCH: ${{ steps.current_branch.outputs.current_branch }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
FORK: ${{ github.event.pull_request.head.repo.fork }}
run: |
# "Set the default branch name..."
if [[ "$GITHUB_REF" != "refs/tags/"* ]]; then
if [[ "$CURRENT_BRANCH" == "$DEFAULT_BRANCH" && "$FORK" != "true" ]]; then
echo "is_default=true" >> "$GITHUB_OUTPUT"
echo "default_branch=$DEFAULT_BRANCH" >> "$GITHUB_OUTPUT"
else
echo "is_default=false" >> "$GITHUB_OUTPUT"
echo "default_branch=$DEFAULT_BRANCH" >> "$GITHUB_OUTPUT"
fi
fi
shell: bash
- id: tag
env:
GITHUB_REF: ${{ github.ref }}
INPUTS_STRIP_TAG_PREFIX: ${{ inputs.strip_tag_prefix }}
run: |
# "Set the tag name..."
if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
REF=$(printf "%q" "$GITHUB_REF")
TAG="${REF/refs\/tags\/$INPUTS_STRIP_TAG_PREFIX/}"
echo "tag=$(eval printf "%s" "$TAG")" >> "$GITHUB_OUTPUT"
echo "is_tag=true" >> "$GITHUB_OUTPUT"
else
echo "is_tag=false" >> "$GITHUB_OUTPUT"
fi
shell: bash
branding:
icon: git-branch
color: white

View File

@ -1,58 +0,0 @@
{
"extends": [
"config:base"
],
"enabled": true,
"prHourlyLimit": 10,
"prConcurrentLimit": 5,
"rebaseWhen": "behind-base-branch",
"addLabels": [
"dependencies",
"merge when passing"
],
"assignees": [
"jackton1"
],
"assignAutomerge": true,
"dependencyDashboard": true,
"dependencyDashboardAutoclose": true,
"lockFileMaintenance": {
"enabled": true,
"automerge": true
},
"nvm": {
"enabled": false
},
"packageRules": [
{
"matchUpdateTypes": [
"minor",
"patch",
"pin",
"digest"
],
"automerge": true,
"rebaseWhen": "behind-base-branch",
"addLabels": [
"merge when passing"
]
},
{
"description": "docker images",
"matchLanguages": [
"docker"
],
"matchUpdateTypes": [
"minor",
"patch",
"pin",
"digest"
],
"rebaseWhen": "behind-base-branch",
"addLabels": [
"merge when passing"
],
"automerge": true
}
]
}