Skip to content

Commit ff5b520

Browse files
authored
add action (#2)
Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com>
1 parent 0922dff commit ff5b520

3 files changed

Lines changed: 63 additions & 13 deletions

File tree

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
[![GitHub license](https://img.shields.io/github/license/op5dev/template?logo=apache&label=License)](LICENSE "Apache License 2.0.")
2-
[![GitHub release tag](https://img.shields.io/github/v/release/op5dev/template?logo=semanticrelease&label=Release)](https://github.com/op5dev/template/releases "View all releases.")
1+
[![GitHub license](https://img.shields.io/github/license/op5dev/current-pr?logo=apache&label=License)](LICENSE "Apache License 2.0.")
2+
[![GitHub release tag](https://img.shields.io/github/v/release/op5dev/current-pr?logo=semanticrelease&label=Release)](https://github.com/op5dev/current-pr/releases "View all releases.")
33
*
4-
[![GitHub repository stargazers](https://img.shields.io/github/stars/op5dev/template)](https://github.com/op5dev/template "Become a stargazer.")
4+
[![GitHub repository stargazers](https://img.shields.io/github/stars/op5dev/current-pr)](https://github.com/op5dev/current-pr "Become a stargazer.")
55

66
# Heading
77

@@ -44,20 +44,20 @@ View [security policy and reporting instructions](SECURITY.md).
4444

4545
## Changelog
4646

47-
View [all notable changes](https://github.com/op5dev/template/releases "Releases.") to this project in [Keep a Changelog](https://keepachangelog.com "Keep a Changelog.") format, which adheres to [Semantic Versioning](https://semver.org "Semantic Versioning.").
47+
View [all notable changes](https://github.com/op5dev/current-pr/releases "Releases.") to this project in [Keep a Changelog](https://keepachangelog.com "Keep a Changelog.") format, which adheres to [Semantic Versioning](https://semver.org "Semantic Versioning.").
4848

4949
> [!TIP]
5050
>
5151
> All forms of **contribution are very welcome** and deeply appreciated for fostering open-source projects.
5252
>
53-
> - [Create a PR](https://github.com/op5dev/template/pulls "Create a pull request.") to contribute changes you'd like to see.
54-
> - [Raise an issue](https://github.com/op5dev/template/issues "Raise an issue.") to propose changes or report unexpected behavior.
55-
> - [Open a discussion](https://github.com/op5dev/template/discussions "Open a discussion.") to discuss broader topics or questions.
56-
> - [Become a stargazer](https://github.com/op5dev/template/stargazers "Become a stargazer.") if you find this project useful.
53+
> - [Create a PR](https://github.com/op5dev/current-pr/pulls "Create a pull request.") to contribute changes you'd like to see.
54+
> - [Raise an issue](https://github.com/op5dev/current-pr/issues "Raise an issue.") to propose changes or report unexpected behavior.
55+
> - [Open a discussion](https://github.com/op5dev/current-pr/discussions "Open a discussion.") to discuss broader topics or questions.
56+
> - [Become a stargazer](https://github.com/op5dev/current-pr/stargazers "Become a stargazer.") if you find this project useful.
5757
</br>
5858
5959
## License
6060

6161
- This project is licensed under the permissive [Apache License 2.0](LICENSE "Apache License 2.0.").
62-
- All works herein are my own, shared of my own volition, and [contributors](https://github.com/op5dev/template/graphs/contributors "Contributors.").
62+
- All works herein are my own, shared of my own volition, and [contributors](https://github.com/op5dev/current-pr/graphs/contributors "Contributors.").
6363
- Copyright 2016-2025 [Rishav Dhar](https://github.com/rdhar "Rishav Dhar's GitHub profile.") — All wrongs reserved.

SECURITY.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Security Policy
22

3-
Placeholder.
3+
Integrating security in your CI/CD pipeline is critical to practicing DevSecOps. This action aims to be secure by default, and it should be complemented with your own review to ensure it meets your (organization's) security requirements.
44

55
## Supported Versions
66

77
| Version | Supported |
88
| :-----: | :-------: |
9-
| v1.X | Yes |
10-
| ≤ v0.X | No |
9+
| ≤ v0.X | Yes |
1110

1211
## Reporting a Vulnerability
1312

14-
You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead, sensitive bugs must be sent by email to <contact@OP5.dev> or reported via [Security Advisory](https://github.com/op5dev/template/security/advisories/new "Create a new security advisory.").
13+
You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead, sensitive bugs must be sent by email to <contact@OP5.dev> or reported via [Security Advisory](https://github.com/op5dev/current-pr/security/advisories/new "Create a new security advisory.").

action.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: Get Current PR Data
3+
author: Rishav Dhar (@rdhar)
4+
description: Get current PR data from any event trigger.
5+
6+
runs:
7+
using: composite
8+
9+
steps:
10+
- shell: bash
11+
run: |
12+
# Populate environment variables.
13+
echo GH_API="X-GitHub-Api-Version:2022-11-28" >> "$GITHUB_ENV"
14+
echo GH_TOKEN="${{ inputs.token }}" >> "$GITHUB_ENV"
15+
16+
- id: data
17+
shell: bash
18+
run: |
19+
# Get PR number using GitHub API for different event triggers.
20+
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
21+
# List PRs associated with the commit, then get the PR number from the head ref or the latest PR.
22+
associated_prs=$(gh api /repos/{owner}/{repo}/commits/${GITHUB_SHA}/pulls --header "$GH_API" --method GET --field per_page=100)
23+
number=$(echo "$associated_prs" | jq --raw-output '(.[] | select(.head.ref == env.GITHUB_REF_NAME) | .number) // .[0].number // 0')
24+
elif [[ "$GITHUB_EVENT_NAME" == "merge_group" ]]; then
25+
# Get the PR number by parsing the ref name.
26+
number=$(echo "${GITHUB_REF_NAME}" | sed -n 's/.*pr-\([0-9]*\)-.*/\1/p')
27+
else
28+
# Get the PR number from the event payload or fallback on 0.
29+
number=${{ github.event.number || github.event.issue.number || 0 }}
30+
fi
31+
echo "number=$number" >> "$GITHUB_OUTPUT"
32+
33+
outputs:
34+
# body:
35+
# description: "The body of the current PR."
36+
# value: ${{ steps.data.outputs.body }}
37+
# branch:
38+
# description: "The branch of the current PR."
39+
# value: ${{ steps.data.outputs.branch }}
40+
number:
41+
description: "The number of the current PR."
42+
value: ${{ steps.data.outputs.number }}
43+
# title:
44+
# description: "The title of the current PR."
45+
# value: ${{ steps.data.outputs.title }}
46+
47+
inputs:
48+
token:
49+
default: ${{ github.token }}
50+
description: "Specify a GitHub token (e.g., `secrets.GITHUB_TOKEN`)."
51+
required: false

0 commit comments

Comments
 (0)