Skip to content

Commit

Permalink
chore(release): 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrako authored and Markus Suonto committed Nov 17, 2021
0 parents commit 50ba0d1
Show file tree
Hide file tree
Showing 9 changed files with 11,060 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

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.

### 0.0.1 (2021-11-17)

## 1.0.0 (2021-11-17)
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Github Action Resolve Pull Request Refs
Tested only for `issue_comment` event. When your workflow triggers on a comment on PR, you can use this action.

TODO: test also on `pull_request` events.

## Inputs

## `token`
**Required:** Github API Token

## Outputs

## `base_ref`
Pull request base ref.

## `head_ref`
Pull request head ref.

## Example usage
```
- name: resolve pr refs
id: refs
uses: eficode/resolve-pr-refs@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
```

## Example usecase
```
on:
issue_comment:
types: [created]
jobs:
fast_forward_merge:
name: ff-merge
if: ${{ github.event.comment.body == '/ff-merge' }}
runs-on: ubuntu-latest
steps:
- name: resolve pr refs
id: refs
uses: eficode/resolve-pr-refs@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: checkout base
uses: actions/checkout@v2
with:
ref: ${{ steps.refs.outputs.base_ref }}
- name: fast forward merge pr
run: |
git fetch
git merge --ff-only origin/${{ steps.refs.outputs.head_ref }}
git push
```

## Building a new version

### Ensure vercel/ncc is installed
```
npm i -g @vercel/ncc
```

### Compile
```
ncc build index.js --license licenses.txt
```

### Tag
```
git tag -a -m "Amazing new release" v1.1
git push --follow-tags
```
15 changes: 15 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Resolve pull request refs'
author: 'Eficode'
description: 'outputs base_ref and head_ref for a PR comment (issue_comment event)'
inputs:
token:
description: Github api token. Usually GITHUB_TOKEN.
required: true
outputs:
base_ref:
description: Pull request base ref
head_ref:
description: Pull request head ref
runs:
using: 'node12'
main: 'dist/index.js'
8,473 changes: 8,473 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

622 changes: 622 additions & 0 deletions dist/licenses.txt

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const core = require('@actions/core');
const github = require('@actions/github');

(async () => {
try {
const prUrl = github.context.payload.issue.pull_request.url;

const githubToken = core.getInput('token');
const octokit = github.getOctokit(githubToken);

const prDetails = await octokit.request(`GET ${prUrl}`);

const status = prDetails.status
const headRef = prDetails.data.head.ref

const baseRef = prDetails.data.base.ref

core.setOutput('base_ref', baseRef);
core.setOutput('head_ref', headRef);
} catch (error) {
core.setFailed(error.message);
}
})();
Loading

0 comments on commit 50ba0d1

Please sign in to comment.