Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use checkout v4 to silence node16 deprecation warnings #18

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
name: "test"
on: push
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# allow running manually
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- run: npm ci
- uses: ./
- run: echo $BRANCH_NAME
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules/

# Editors
.vscode
.idea

# Logs
logs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- run: npm ci
- uses: nelonoel/[email protected]
# Use branch name for whatever purpose
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ branding:
icon: 'git-branch'
color: 'blue'
runs:
using: 'node12'
using: 'node20'
main: 'dist/index.js'
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ const core = require('@actions/core');

async function run() {
try {
core.exportVariable('BRANCH_NAME', process.env.GITHUB_REF.split('/').slice(2).join('/'));
const event = JSON.parse( readFileSync( GITHUB_EVENT_PATH, 'utf8' ) );
const isPullRequest = !! event.pull_request;
let branchName;
if ( this.isPullRequest ) {
branchName = event.pull_request.head.ref;
} else {
branchName = event.ref.substr( 11 );
}
core.exportVariable('BRANCH_NAME', branchName);
}
catch (error) {
core.setFailed(error.message);
Expand Down
98 changes: 61 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"homepage": "https://github.com/nelonoel/branch-name#readme",
"dependencies": {
"@actions/core": "^1.2.6"
"@actions/core": "^1.9.1"
},
"devDependencies": {
"@zeit/ncc": "^0.20.5",
Expand Down