-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yaml
104 lines (104 loc) · 3.57 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Pre-commit Optimized for ScribeMD/pre-commit-hooks
author: Kurt von Laven
description: >
Install pre-commit via asdf and Poetry; then run pre-commit hooks with extra
optimizations for ScribeMD/pre-commit-hooks.
branding:
icon: wind
color: orange
inputs:
bump:
description: >
If "true," run the Commitizen action on push to main to commit a version
bump and tag a release if there are any release-worthy changes. Commitizen
relies on tags in order to perform an incremental release, so you must pass
fetch-depth: 0 to the official GitHub checkout action unless bump is
"false."
required: false
default: "true"
runs:
using: composite
steps:
- name: Get operating system name and version.
id: os
run: echo "::set-output name=image::$ImageOS"
shell: bash
- name: Install asdf.
uses: asdf-vm/actions/setup@v1.1.0
with:
asdf_branch: v0.10.2
- name: Cache asdf and asdf-managed tools.
uses: actions/cache@v3.0.5
id: asdf-cache
with:
path: ${{ env.ASDF_DIR }}
key: >
asdf-v0.10.2-${{ steps.os.outputs.image }}-${{
hashFiles('**/.tool-versions')
}}
- name: Install asdf-managed tools based on .tool-versions.
if: steps.asdf-cache.outputs.cache-hit != 'true'
uses: asdf-vm/actions/install@v1.1.0
- name: Add Poetry and its dependencies to PATH.
run: |
for version in "$ASDF_DIR/installs/poetry/"*; do
echo "$version/bin" >>"$GITHUB_PATH"
done
echo "${{ github.workspace }}/.venv/bin" >>"$GITHUB_PATH"
shell: bash
- name: Cache Poetry dependencies.
uses: actions/cache@v3.0.5
with:
path: .venv
key: >
poetry-${{ steps.os.outputs.image }}-${{
hashFiles('**/poetry.lock')
}}
- name: Install Poetry dependencies.
run: poetry install
shell: bash
- name: Get npm cache directory.
id: npm-cache
run: |
npm_cache="$(npm config get cache)"
echo "::set-output name=path::$npm_cache"
shell: bash
- name: Cache npm dependencies.
uses: actions/cache@v3.0.5
with:
path: ${{ steps.npm-cache.outputs.path }}
key: >
node-${{ steps.os.outputs.image }}-${{ hashFiles(
'.mega-linter.yaml',
'.pre-commit-config.yaml',
'.pre-commit-hooks.yaml'
) }}
- name: Use Docker in rootless mode.
uses: ScribeMD/rootless-docker@0.1.7
- name: Cache Docker images.
uses: ScribeMD/docker-cache@0.1.4
with:
key: >
docker-${{ steps.os.outputs.image }}-${{
hashFiles('.pre-commit-config.yaml')
}}
- name: Run pre-push hooks.
uses: pre-commit/action@v3.0.0
with:
extra_args: "--all-files --hook-stage push"
env:
SKIP: no-commit-to-branch
- name: Uninstall pre-commit hooks. # Don't break subsequent Git commands.
run: pre-commit uninstall
shell: bash
- name: Push a commit to main to bump version and update changelog.
if: >
inputs.bump == 'true'
&& github.event_name == 'push' && github.ref == 'refs/heads/main'
&& !startsWith(github.event.head_commit.message, 'bump:')
uses: commitizen-tools/commitizen-action@0.14.1
with:
git_name: commitizen-github-action[bot]
git_email: commitizen-github-action[bot]@users.noreply.github.com
github_token: ${{ github.token }}
commitizen_version: 2.27.1 # Keep in sync with .pre-commit-config.yaml and pyproject.toml.