mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-06-10 16:43:09 +00:00
feat: expose GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -50,6 +50,7 @@ jobs:
|
|||||||
echo $GITHUB_BASE_REF_SLUG_URL
|
echo $GITHUB_BASE_REF_SLUG_URL
|
||||||
echo $GITHUB_EVENT_REF_SLUG_URL
|
echo $GITHUB_EVENT_REF_SLUG_URL
|
||||||
echo $GITHUB_SHA_SHORT
|
echo $GITHUB_SHA_SHORT
|
||||||
|
echo $GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT
|
||||||
|
|
||||||
test-win:
|
test-win:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@@ -68,3 +69,4 @@ jobs:
|
|||||||
echo $env:GITHUB_BASE_REF_SLUG_URL
|
echo $env:GITHUB_BASE_REF_SLUG_URL
|
||||||
echo $env:GITHUB_EVENT_REF_SLUG_URL
|
echo $env:GITHUB_EVENT_REF_SLUG_URL
|
||||||
echo $env:GITHUB_SHA_SHORT
|
echo $env:GITHUB_SHA_SHORT
|
||||||
|
echo $env:GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -41,6 +41,7 @@ Others `Slug`-ish commands are available:
|
|||||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
||||||
echo "Short SHA variables"
|
echo "Short SHA variables"
|
||||||
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||||
|
echo " pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
Read [default environment variables][3] page for more information.
|
Read [default environment variables][3] page for more information.
|
||||||
@@ -98,6 +99,15 @@ The commit SHA that triggered the workflow
|
|||||||
| ---------------------------------------- | ---------------- |
|
| ---------------------------------------- | ---------------- |
|
||||||
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
||||||
|
|
||||||
|
### GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT
|
||||||
|
|
||||||
|
Short the value of `github.event.pull_request.head.sha` that represents the last commit
|
||||||
|
used for triggering an action for a pull request.
|
||||||
|
|
||||||
|
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
|
||||||
|
| ---------------------------------------- | ---------------------------------------- |
|
||||||
|
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
||||||
|
|
||||||
### Use slug variable in an URL
|
### Use slug variable in an URL
|
||||||
|
|
||||||
In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>\_SLUG** as subdomain to be compliant.
|
In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>\_SLUG** as subdomain to be compliant.
|
||||||
|
|||||||
4
dist/index.js
vendored
4
dist/index.js
vendored
@@ -116,6 +116,7 @@ const GITHUB_BASE_REF_SLUG_URL = 'GITHUB_BASE_REF_SLUG_URL';
|
|||||||
const GITHUB_SHA_SHORT = 'GITHUB_SHA_SHORT';
|
const GITHUB_SHA_SHORT = 'GITHUB_SHA_SHORT';
|
||||||
const GITHUB_EVENT_REF_SLUG = 'GITHUB_EVENT_REF_SLUG';
|
const GITHUB_EVENT_REF_SLUG = 'GITHUB_EVENT_REF_SLUG';
|
||||||
const GITHUB_EVENT_REF_SLUG_URL = 'GITHUB_EVENT_REF_SLUG_URL';
|
const GITHUB_EVENT_REF_SLUG_URL = 'GITHUB_EVENT_REF_SLUG_URL';
|
||||||
|
const GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT = 'GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT';
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
@@ -126,6 +127,9 @@ function run() {
|
|||||||
core.exportVariable(GITHUB_EVENT_REF_SLUG, slug_1.slugref(eventData.ref));
|
core.exportVariable(GITHUB_EVENT_REF_SLUG, slug_1.slugref(eventData.ref));
|
||||||
core.exportVariable(GITHUB_EVENT_REF_SLUG_URL, slug_1.slugurlref(eventData.ref));
|
core.exportVariable(GITHUB_EVENT_REF_SLUG_URL, slug_1.slugurlref(eventData.ref));
|
||||||
}
|
}
|
||||||
|
else if (eventData.hasOwnProperty('pull_request')) {
|
||||||
|
core.exportVariable(GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT, slug_1.shortsha(eventData.pull_request.head.sha));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exportSlug(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG);
|
exportSlug(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG);
|
||||||
exportSlugUrl(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL);
|
exportSlugUrl(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL);
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
11
package-lock.json
generated
11
package-lock.json
generated
@@ -3625,7 +3625,8 @@
|
|||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
|
||||||
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"handlebars": {
|
"handlebars": {
|
||||||
"version": "4.7.6",
|
"version": "4.7.6",
|
||||||
@@ -4210,6 +4211,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-docker": "^2.0.0"
|
"is-docker": "^2.0.0"
|
||||||
}
|
}
|
||||||
@@ -5589,6 +5591,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz",
|
||||||
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
"integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"growly": "^1.3.0",
|
"growly": "^1.3.0",
|
||||||
"is-wsl": "^2.2.0",
|
"is-wsl": "^2.2.0",
|
||||||
@@ -10396,7 +10399,8 @@
|
|||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
||||||
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"signal-exit": {
|
"signal-exit": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
@@ -11461,7 +11465,8 @@
|
|||||||
"version": "8.3.1",
|
"version": "8.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
|
||||||
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"v8-compile-cache": {
|
"v8-compile-cache": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ const GITHUB_BASE_REF_SLUG_URL = 'GITHUB_BASE_REF_SLUG_URL'
|
|||||||
const GITHUB_SHA_SHORT = 'GITHUB_SHA_SHORT'
|
const GITHUB_SHA_SHORT = 'GITHUB_SHA_SHORT'
|
||||||
const GITHUB_EVENT_REF_SLUG = 'GITHUB_EVENT_REF_SLUG'
|
const GITHUB_EVENT_REF_SLUG = 'GITHUB_EVENT_REF_SLUG'
|
||||||
const GITHUB_EVENT_REF_SLUG_URL = 'GITHUB_EVENT_REF_SLUG_URL'
|
const GITHUB_EVENT_REF_SLUG_URL = 'GITHUB_EVENT_REF_SLUG_URL'
|
||||||
|
const GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT =
|
||||||
|
'GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT'
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@@ -38,6 +40,11 @@ async function run(): Promise<void> {
|
|||||||
GITHUB_EVENT_REF_SLUG_URL,
|
GITHUB_EVENT_REF_SLUG_URL,
|
||||||
slugurlref(eventData.ref)
|
slugurlref(eventData.ref)
|
||||||
)
|
)
|
||||||
|
} else if (eventData.hasOwnProperty('pull_request')) {
|
||||||
|
core.exportVariable(
|
||||||
|
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT,
|
||||||
|
shortsha(eventData.pull_request.head.sha)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user