Skip to content

Commit

Permalink
Merge pull request #1 from Drafteame/chore/add-base-action
Browse files Browse the repository at this point in the history
chore: add base action code
  • Loading branch information
danteay authored May 22, 2024
2 parents 6f5bb39 + 6b6a9e3 commit 934bfa6
Show file tree
Hide file tree
Showing 24 changed files with 6,362 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .cz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[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 = false
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)"

[tool.commitizen.customize.bump_map]
break = "MAJOR"
build = "MINOR"
feat = "MINOR"
revert = "MINOR"
fix = "PATCH"
refactor = "PATCH"
style = "PATCH"
test = "PATCH"
deps = "PATCH"
chore = "PATCH"
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.github/
node_modules/
scripts/
tests/
12 changes: 12 additions & 0 deletions .github/dependaboot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'daily'

- package-ecosystem: 'npm'
directory: '.'
schedule:
interval: 'daily'
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@v3.3.0

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

- 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: Lint
run: npm run test

commit_lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
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
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Release

on:
push:
branches:
- main

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

permissions:
contents: write
packages: 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@v4.1.5
with:
fetch-depth: 0
token: '${{ secrets.ACCESS_TOKEN }}'
ref: 'main'

- 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
- name: Set up Python
uses: actions/setup-python@v5.1.0
with:
python-version: 3.11

- name: Create bump and changelog
id: cz
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.8.0
with:
github_token: ${{ secrets.ACCESS_TOKEN }}
repository: ${{ github.repository }}
branch: 'main'
directory: .
tags: true

- name: Print Version
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"

build:
runs-on: ubuntu-latest
needs:
- bump_version
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false

- name: Set repo name
run: |
repo=$(echo "ghcr.io/${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "REPO=$repo" >> $GITHUB_ENV
- name: Build and push
run: |
docker buildx build --platform linux/amd64,linux/arm64 -t ${{ env.REPO }}:latest --push .
docker buildx build --platform linux/amd64,linux/arm64 -t ${{ env.REPO }}:${{ needs.bump_version.outputs.version }} --push .
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/
.vscode/

node_modules/

.DS_Store
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
hooks:
- id: eslint
name: eslint
entry: npm run lint
language: node

- id: prettier
name: prettier
entry: npm run format
language: node

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

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.27.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/
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 80
}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:20-alpine

LABEL "com.github.actions.icon"="database"
LABEL "com.github.actions.color"="blue"
LABEL "com.github.actions.name"="s3-app-configure-action"
LABEL "com.github.actions.description"="Github action to help synchronize configuration files to an s3 bucket"
LABEL "org.opencontainers.image.source"="https://github.com/Drafteame/s3-app-configure-action"

COPY . /action
WORKDIR /action

RUN npm install --omit=dev

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 @@
# s3-app-configure-action
Github action to help syncronize configuration files to an s3 bucket

GitHub action to help synchronize configuration files to an s3 bucket
34 changes: 34 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 's3-app-configure-action'

description: 'Github action to help synchronize configuration files to an s3 bucket'

branding:
icon: database
color: blue

inputs:
bucket:
description: 'S3 bucket name to store and sync configurations'
required: true
source:
description: 'Source file that should be synced'
required: true
destination:
description: 'Destination path on s3 bucket including final file name'
required: true
aws_access_key:
description: 'AWS Access Key Id'
required: true
aws_secret_key:
description: 'AWS Secret Access Key'
required: true
aws_region:
description: 'AWS Region (default us-east-1)'
required: false
dry_run:
description: 'Do not create any persistent changes over the configurations and just show an overview of the changes'
required: false

runs:
using: 'docker'
image: 'Dockerfile'
19 changes: 19 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as imp from 'eslint-plugin-import';
import prettier from 'eslint-plugin-prettier';

export default [
{
files: ['**/*.js'],
plugins: {
import: imp,
prettier: prettier,
},
rules: {
// Example of custom rules, you can add more or modify as needed
'import/prefer-default-export': 'off',
'no-console': 'warn',
'no-unused-vars': 'warn',
'prettier/prettier': 'error', // Ensures that Prettier issues are flagged as errors
},
},
];
Loading

0 comments on commit 934bfa6

Please sign in to comment.