Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Initial version #1

Merged
merged 21 commits into from
Jul 4, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
30c3ab5
docs(README): remove WIP note
oscard0m Jul 2, 2021
410d48c
build(package): initial version
oscard0m Jul 2, 2021
0465b43
build(package): lock file
oscard0m Jul 2, 2021
ebe67e7
build(gitignore): node_modules
oscard0m Jul 2, 2021
f588300
feat: initial version
oscard0m Jul 2, 2021
9f44f3b
docs(README): badges
oscard0m Jul 2, 2021
f9749ff
docs(README): usage
oscard0m Jul 2, 2021
59a6176
ci(release): initial version
oscard0m Jul 2, 2021
838327f
ci(test): initial version
oscard0m Jul 2, 2021
c134804
feat(script): implement logic to modify workflows with setup-node action
oscard0m Jul 3, 2021
4b3049f
docs(readme): remove --cache command from example to avoid issues pas…
oscard0m Jul 4, 2021
699ea6a
refactor(script): remove and rename global variables and add missing …
oscard0m Jul 4, 2021
8c93edf
fix(script): if 'with' statement does not exist, create it
oscard0m Jul 4, 2021
e6fbc3c
refactor(script): remove label creation when opening a PR
oscard0m Jul 4, 2021
15b446b
refactor(script): use for...of instead of for when iterating yaml file
oscard0m Jul 4, 2021
87214cc
fix(script): branch has to be created before adding a new git referen…
oscard0m Jul 4, 2021
1ab0437
refactor(script): remove unused if(!ref) statement
oscard0m Jul 4, 2021
667332b
build(deps): add octokit-plugin-create-pull-request
oscard0m Jul 4, 2021
dd06aee
feat(script): integrate logic with octokit-plugin-create-pull-request
oscard0m Jul 4, 2021
142cf15
fix(script): do not open PR if no cache statement added to any workflow
oscard0m Jul 4, 2021
69b6a9b
feat(script): improve PR body opened by this script
oscard0m Jul 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release
on:
push:
branches:
- main

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]

jobs:
test_matrix:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: ["12", "14"]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm test

# The "test" step can be required in branch protection and does not
# change each time the test matrix changes.
test:
runs-on: ubuntu-latest
needs: test_matrix
steps:
- run: echo ok
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
# 🚧 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)

# octoherd-script-add-cache-to-node-github-action

> Add cache parameter to GitHub Actions using setup-node

[![@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)
[![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)

## Usage

Minimal usage

```js
npx octoherd-script-add-cache-to-node-github-action
```

Pass all options as CLI flags to avoid user prompts

```js
npx octoherd-script-add-cache-to-node-github-action \
-T ghp_0123456789abcdefghjklmnopqrstuvwxyzA \
-R "oscard0m/*" \
--cache "npm" | "yarn"
oscard0m marked this conversation as resolved.
Show resolved Hide resolved
```

## Options

| option | type | description |
| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--cache` | string | Select which package manager you want to use for caching. Defaults to "npm" |
| `--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 |
| `--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 |
| `--octoherd-bypass-confirms` | boolean | Bypass prompts to confirm mutating requests |

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)
Expand Down
6 changes: 6 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

import { script } from "./script.js";
import { run } from "@octoherd/cli/run";

run(script);
Loading