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: add first skeleton of the action #1

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions .cz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool]
[tool.commitizen]
name = "cz_customize"
version = "0.0.0"
tag_format = "v$version"
bump_message = "bump: release $current_version → $new_version [skip-ci]"
update_changelog_on_bump = true
version_files = [
"package.json:version",
]

[tool.commitizen.customize]
schema_pattern = "(break|build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump|deps)(\\(\\S+\\))?!?:(\\s.*)"
bump_pattern = "^(break|build|feat|fix|refactor|style|test|revert|deps|docs|ci|chore)"
bump_map = {"break" = "MAJOR", "build" = "MINOR", "feat" = "MINOR", "revert" = "MINOR", "fix" = "PATCH", "refactor" = "PATCH", "style" = "PATCH", "test" = "PATCH", "ci" = "PATCH", "deps" = "PATCH", "chore" = "PATCH", "docs" = "PATCH"}
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.github/
.cz.toml
.eslintrc.json
.pre-commit-config.yaml
.prettierignore
.prettierrc.json
tests/
15 changes: 15 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": ["plugin:prettier/recommended"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"env": {
"es6": true,
"node": true
}
}
13 changes: 13 additions & 0 deletions .github/dependaboot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "npm"
directory: "."
schedule:
interval: "daily"
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.

## Task Context

### What is the current behavior?

<!-- current functionality without PR -->

### What is the new behavior?

<!-- expected functionality with PR -->

### Additional Context

<!-- Add here any additional context you think is important. -->
32 changes: 32 additions & 0 deletions .github/workflows/cleanup_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Cleanup caches by a branch

on:
pull_request:
types:
- closed

jobs:
cleanup:
name: Cleanup
runs-on: ubuntu-latest
steps:
- name: Cleanup all caches for repo
run: |
gh extension install actions/gh-actions-cache

REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"

echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )

## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61 changes: 61 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Pull Request

on:
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Install dependencies
run: npm install

- name: Lint
run: npm run lint

# test:
# name: Test
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Install NodeJS
# uses: actions/setup-node@v3
# with:
# node-version: "20"

# - name: Install dependencies
# run: npm install

# - name: Execute tests
# run: npm run test

commit_lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3.3.0
with:
token: "${{ secrets.ACCESS_TOKEN }}"
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4.7.0
with:
python-version: 3.11

- name: Install Commitizen
run: pip install -U commitizen

- name: Check commits
run: cz check --rev-range origin/main..HEAD
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release

on:
push:
branches:
- main

env:
GIT_USER_EMAIL: ${{ secrets.GIT_EMAIL }}
GIT_USER_NAME: ${{ secrets.GIT_NAME }}

permissions:
contents: write

jobs:
bump_version:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
name: "Bump version"
outputs:
version: ${{ steps.cz.outputs.version }}
steps:
- name: Check out
uses: actions/checkout@v3
with:
fetch-depth: 0
token: "${{ secrets.ACCESS_TOKEN }}"
ref: "main"

- name: Set up Python
uses: actions/setup-python@v4.7.0
with:
python-version: 3.11

- name: Config Git User
run: |
git config --local user.email "$GIT_USER_EMAIL"
git config --local user.name "$GIT_USER_NAME"
git config --local pull.ff only

- id: cz
name: Create bump and changelog
run: |
python -m pip install -U commitizen
cz bump --yes
export REV=`cz version --project`
echo "version=\"v$REV\"" >> $GITHUB_OUTPUT

- name: Push changes
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.ACCESS_TOKEN }}
repository: "Drafteame/ejson-action"
branch: "main"
directory: .
tags: true

- name: Print Version
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea/
.vscode/

node_modules/
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.50.0
hooks:
- id: eslint
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
types: [file]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml

- repo: https://github.com/commitizen-tools/commitizen
rev: 3.10.0
hooks:
- id: commitizen
stages: [commit-msg]
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore artifacts:
build/
coverage/
node_modules/
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:20

RUN mkdir -p /opt/ejson/keys

COPY . /action
WORKDIR /action

RUN chmod +x ejson-1.4.1

RUN npm install --production

ENTRYPOINT ["node", "/action/index.js"]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# ejson-action
Github action that helps to execute encription and decription of ejson files

Simple github action that helps to execute encryption and decryption of json files using the ejson cli
25 changes: 25 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "ejson action"
description: "Execute encryption and decryption of json files using ejson"

branding:
icon: database
color: blue

inputs:
action:
description: "Possible values should be encrypt or decrypt"
required: true
file_path:
description: "Path to the source ejson file"
required: true
private_key:
description: "Private key needed to decrypt action"
required: false

outputs:
decrypt:
description: "List of changes made to the secret"

runs:
using: "docker"
image: "Dockerfile"
Binary file added ejson-1.4.1
Binary file not shown.
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import core from "@actions/core";

import Action from "./src/Action.js";

const main = async () => {
const action = new Action(
core.getInput("action"),
core.getInput("file_path"),
core.getInput("private_key"),
);

const decrypted = await action.run();

core.info(`Decrypted JSON: ${decrypted}`);
};

main();
Loading