File tree Expand file tree Collapse file tree 9 files changed +11060
-0
lines changed Expand file tree Collapse file tree 9 files changed +11060
-0
lines changed Original file line number Diff line number Diff line change 1+ node_modules /
Original file line number Diff line number Diff line change 1+ # Changelog
2+
3+ All notable changes to this project will be documented in this file. See [ standard-version] ( https://github.com/conventional-changelog/standard-version ) for commit guidelines.
4+
5+ ### 0.0.1 (2021-11-17)
6+
7+ ## 1.0.0 (2021-11-17)
Original file line number Diff line number Diff line change 1+ # Github Action Resolve Pull Request Refs
2+ Tested only for ` issue_comment ` event. When your workflow triggers on a comment on PR, you can use this action.
3+
4+ TODO: test also on ` pull_request ` events.
5+
6+ ## Inputs
7+
8+ ## ` token `
9+ ** Required:** Github API Token
10+
11+ ## Outputs
12+
13+ ## ` base_ref `
14+ Pull request base ref.
15+
16+ ## ` head_ref `
17+ Pull request head ref.
18+
19+ ## Example usage
20+ ```
21+ - name: resolve pr refs
22+ id: refs
23+ uses: eficode/resolve-pr-refs@main
24+ with:
25+ token: ${{ secrets.GITHUB_TOKEN }}
26+ ```
27+
28+ ## Example usecase
29+ ```
30+ on:
31+ issue_comment:
32+ types: [created]
33+ jobs:
34+ fast_forward_merge:
35+ name: ff-merge
36+ if: ${{ github.event.comment.body == '/ff-merge' }}
37+ runs-on: ubuntu-latest
38+ steps:
39+ - name: resolve pr refs
40+ id: refs
41+ uses: eficode/resolve-pr-refs@main
42+ with:
43+ token: ${{ secrets.GITHUB_TOKEN }}
44+ - name: checkout base
45+ uses: actions/checkout@v2
46+ with:
47+ ref: ${{ steps.refs.outputs.base_ref }}
48+ - name: fast forward merge pr
49+ run: |
50+ git fetch
51+ git merge --ff-only origin/${{ steps.refs.outputs.head_ref }}
52+ git push
53+ ```
54+
55+ ## Building a new version
56+
57+ ### Ensure vercel/ncc is installed
58+ ```
59+ npm i -g @vercel/ncc
60+ ```
61+
62+ ### Compile
63+ ```
64+ ncc build index.js --license licenses.txt
65+ ```
66+
67+ ### Tag
68+ ```
69+ git tag -a -m "Amazing new release" v1.1
70+ git push --follow-tags
71+ ```
Original file line number Diff line number Diff line change 1+ name : ' Resolve pull request refs'
2+ author : ' Eficode'
3+ description : ' outputs base_ref and head_ref for a PR comment (issue_comment event)'
4+ inputs :
5+ token :
6+ description : Github api token. Usually GITHUB_TOKEN.
7+ required : true
8+ outputs :
9+ base_ref :
10+ description : Pull request base ref
11+ head_ref :
12+ description : Pull request head ref
13+ runs :
14+ using : ' node12'
15+ main : ' dist/index.js'
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ const core = require ( '@actions/core' ) ;
2+ const github = require ( '@actions/github' ) ;
3+
4+ ( async ( ) => {
5+ try {
6+ const prUrl = github . context . payload . issue . pull_request . url ;
7+
8+ const githubToken = core . getInput ( 'token' ) ;
9+ const octokit = github . getOctokit ( githubToken ) ;
10+
11+ const prDetails = await octokit . request ( `GET ${ prUrl } ` ) ;
12+
13+ const status = prDetails . status
14+ const headRef = prDetails . data . head . ref
15+
16+ const baseRef = prDetails . data . base . ref
17+
18+ core . setOutput ( 'base_ref' , baseRef ) ;
19+ core . setOutput ( 'head_ref' , headRef ) ;
20+ } catch ( error ) {
21+ core . setFailed ( error . message ) ;
22+ }
23+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments