Skip to content

Commit 04aa142

Browse files
goruhaosterman
andauthored
Get the PR info by ID or associated commit (#12)
## What * Extend GHA to support retrieving PR by ID * Replaced usage of npm with yarn * Added tests for getting PR by PR ID * Copy `package.json` and `jest` configs from cloudposse typescript actions ## Why * Working with issue comments, we have PR ID instead of commit SHA in the context. * Standardazise toolchain * Improve test coverage * Standardazise config and workflows ## References * https://github.com/cloudposse/.github/pull/117/files#diff-90dcedcd84c3e38439050ef7ae1df7289d0c0b842f39f9f84fbd33c4de8f122fR22 Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]> --------- Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
1 parent 11f1a88 commit 04aa142

28 files changed

+21293
-33718
lines changed

.eslintignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
dist/
21
lib/
2+
dist/
33
node_modules/
4-
jest.config.js
4+
coverage/

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
* text=auto
1+
* text=auto eol=lf
2+
23
dist/** -diff linguist-generated=true

.github/settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ _extends: .github
33

44
repository:
55
name: get-pr
6-
description: Get the PR info associated with the commit
6+
description: Get the PR info by ID or associated commit
77
homepage: https://cloudposse.com/accelerate
88
topics: "github-action"

.github/workflows/build-and-test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
node-version-file: package.json
2929
cache: yarn
3030
- name: install dependencies
31-
run: yarn install --frozen-lockfile --prefer-offline
31+
run: yarn add ci
3232
- uses: cloudposse/github-action-setup-atmos@v2
3333
with:
3434
install-wrapper: false
@@ -43,10 +43,10 @@ jobs:
4343
with:
4444
node-version: '20'
4545
cache: 'npm'
46-
- run: npm ci
46+
- run: yarn add ci
4747
- name: Build Action
4848
run: |
49-
npm run build
49+
yarn build
5050
- name: Run Action
5151
uses: ./
5252
id: pr
@@ -66,10 +66,10 @@ jobs:
6666
with:
6767
node-version: '20'
6868
cache: 'npm'
69-
- run: npm ci
69+
- run: yarn add ci
7070
- name: Build Action
7171
run: |
72-
npm run build
72+
yarn build
7373
- name: Run Action
7474
uses: ./
7575
id: pr

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ Thumbs.db
9696

9797
# Ignore built ts files
9898
__tests__/runner/*
99-
lib/**/*
100-
101-
#Idea
102-
.idea/
10399

100+
# IDE files
101+
.idea
102+
.vscode
103+
*.code-workspace
104104

105105
.build-harness
106106
build-harness

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.6.0

.prettierignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dist/
2-
lib/
3-
node_modules/
2+
node_modules/
3+
coverage/

.prettierrc.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
"useTabs": false,
55
"semi": false,
66
"singleQuote": true,
7+
"quoteProps": "as-needed",
8+
"jsxSingleQuote": false,
79
"trailingComma": "none",
8-
"bracketSpacing": false,
9-
"arrowParens": "avoid"
10+
"bracketSpacing": true,
11+
"bracketSameLine": true,
12+
"arrowParens": "avoid",
13+
"proseWrap": "always",
14+
"htmlWhitespaceSensitivity": "css",
15+
"endOfLine": "lf"
1016
}

README.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,44 @@ references: []
3535

3636
# How to use this project
3737
usage: |-
38+
This action will retrieve the PR metadata by `id` (PR number) or commit `sha`.
39+
The `id` takes precedence over `sha`, if both are passed.
40+
41+
### By ID
42+
43+
```yaml
44+
on:
45+
pull_request:
46+
branches:
47+
- main
48+
types: [opened, synchronize, reopened]
49+
50+
jobs:
51+
pr:
52+
name: PR Info
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: cloudposse-github-actions/get-pr@main
56+
id: pr
57+
with:
58+
id: ${{ github.event.number }}
59+
outputs:
60+
base: ${{ fromJSON(steps.pr.outputs.pr).base.sha }}
61+
head: ${{ fromJSON(steps.pr.outputs.pr).head.sha }}
62+
found: ${{ steps.pr.outputs.found }}
63+
json: ${{ steps.pr.outputs.json }}
64+
number: ${{ steps.pr.outputs.number }}
65+
title: ${{ steps.pr.outputs.title }}
66+
body: ${{ steps.pr.outputs.body }}
67+
url: ${{ steps.pr.outputs.url }}
68+
created_at: ${{ steps.pr.outputs.created_at }}
69+
merged_at: ${{ steps.pr.outputs.merged_at }}
70+
closed_at: ${{ steps.pr.outputs.closed_at }}
71+
labels: ${{ steps.pr.outputs.labels }}
72+
```
73+
74+
### By SHA
75+
3876
```yaml
3977
on:
4078
push:
@@ -62,6 +100,7 @@ usage: |-
62100
closed_at: ${{ steps.pr.outputs.closed_at }}
63101
labels: ${{ steps.pr.outputs.labels }}
64102
```
103+
65104
include:
66105
- "docs/github-action.md"
67106

__tests__/.eslintrc.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)