Skip to content

Commit f08d2b8

Browse files
authored
feat: Initial version (#1)
* docs(README): remove WIP note * build(package): initial version * build(package): lock file * build(gitignore): node_modules * feat: initial version * docs(README): badges * docs(README): usage * ci(release): initial version * ci(test): initial version * feat(script): implement logic to modify workflows with setup-node action * docs(readme): remove --cache command from example to avoid issues pasting the command with a pipe * refactor(script): remove and rename global variables and add missing jsdoc * fix(script): if 'with' statement does not exist, create it * refactor(script): remove label creation when opening a PR * refactor(script): use for...of instead of for when iterating yaml file * fix(script): branch has to be created before adding a new git reference to that branch * refactor(script): remove unused if(!ref) statement * build(deps): add octokit-plugin-create-pull-request * feat(script): integrate logic with octokit-plugin-create-pull-request * fix(script): do not open PR if no cache statement added to any workflow * feat(script): improve PR body opened by this script
1 parent 821e060 commit f08d2b8

File tree

8 files changed

+1165
-2
lines changed

8 files changed

+1165
-2
lines changed

.github/workflows/release.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
release:
9+
name: release
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v2
14+
with:
15+
node-version: 12
16+
- uses: actions/cache@v2
17+
with:
18+
path: ~/.npm
19+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
20+
restore-keys: |
21+
${{ runner.os }}-node-
22+
- run: npm ci
23+
- run: npx semantic-release
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
test_matrix:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node_version: ["12", "14"]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Use Node.js ${{ matrix.node_version }}
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: ${{ matrix.node_version }}
22+
- uses: actions/cache@v2
23+
with:
24+
path: ~/.npm
25+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
26+
restore-keys: |
27+
${{ runner.os }}-node-
28+
- run: npm ci
29+
- run: npm test
30+
31+
# The "test" step can be required in branch protection and does not
32+
# change each time the test matrix changes.
33+
test:
34+
runs-on: ubuntu-latest
35+
needs: test_matrix
36+
steps:
37+
- run: echo ok

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
1-
# 🚧 WORK IN PROGRESS. See [#1](https://github.com/oscard0m/octoherd-script-add-cache-to-node-github-action/pull/1) | [Preview](https://github.com/oscard0m/octoherd-script-add-cache-to-node-github-action/tree/initial-version)
2-
31
# octoherd-script-add-cache-to-node-github-action
42

53
> Add cache parameter to GitHub Actions using setup-node
64
5+
[![@latest](https://img.shields.io/npm/v/octoherd-script-add-cache-to-node-github-action.svg)](https://www.npmjs.com/package/octoherd-script-add-cache-to-node-github-action)
6+
[![Build Status](https://github.com/oscard0m/octoherd-script-add-cache-to-node-github-action/workflows/Test/badge.svg)](https://github.com/oscard0m/octoherd-script-add-cache-to-node-github-action/actions?query=workflow%3ATest+branch%3Amain)
7+
8+
## Usage
9+
10+
Minimal usage
11+
12+
```js
13+
npx octoherd-script-add-cache-to-node-github-action
14+
```
15+
16+
Pass all options as CLI flags to avoid user prompts
17+
18+
```js
19+
npx octoherd-script-add-cache-to-node-github-action \
20+
-T ghp_0123456789abcdefghjklmnopqrstuvwxyzA \
21+
-R "oscard0m/*"
22+
```
23+
24+
## Options
25+
26+
| option | type | description |
27+
| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
28+
| `--cache` | string | Select which package manager you want to use for caching. Defaults to "npm" |
29+
| `--octoherd-token`, `-T` | string | A personal access token ([create](https://github.com/settings/tokens/new?scopes=repo)). Script will create one if option is not set |
30+
| `--octoherd-repos`, `-R` | array of strings | One or multiple space-separated repositories in the form of `repo-owner/repo-name`. `repo-owner/*` will find all repositories for one owner. `*` will find all repositories the user has access to. Will prompt for repositories if not set |
31+
| `--octoherd-bypass-confirms` | boolean | Bypass prompts to confirm mutating requests |
32+
733
## Contributing
834

935
See [CONTRIBUTING.md](CONTRIBUTING.md)

cli.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env node
2+
3+
import { script } from "./script.js";
4+
import { run } from "@octoherd/cli/run";
5+
6+
run(script);

0 commit comments

Comments
 (0)