31
31
- name : Version files
32
32
shell : bash
33
33
run : |
34
- # Find Node and Python versions
35
-
36
- # Try to use local repo .node-version
37
- NODE_VERSION="${NODE_VERSION:-$(cat ".node-version" || true)}"
38
- # Try to use existing version
39
- NODE_VERSION="${NODE_VERSION:-$(node --version || true)}"
40
- # Try to use action default version
41
- NODE_VERSION="${NODE_VERSION:-$(cat "$GITHUB_ACTION_PATH/.node-version")}"
42
- # Write back the file if it doesn't exist
43
- [[ -f .node-version ]] || { echo "${NODE_VERSION#v}" > .node-version; echo "CLEAN_NODE_VERSION=true" >> "$GITHUB_ENV"; }
44
- echo "NODE_VERSION=${NODE_VERSION}" >> "$GITHUB_ENV"
45
-
46
- # Try to use local repo .python-version
47
- PYTHON_VERSION="${PYTHON_VERSION:-$(cat ".python-version" || true)}"
48
- # Try to use existing version
49
- PYTHON_VERSION="${PYTHON_VERSION:-$(python --version || true)}"
50
- # Try to use action default version
51
- PYTHON_VERSION="${PYTHON_VERSION:-$(cat "$GITHUB_ACTION_PATH/.python-version")}"
52
- # Strip leading "Python " if it exists
53
- PYTHON_VERSION="${PYTHON_VERSION//Python /}"
54
- # Write back the file if it doesn't exist
55
- [[ -f .python-version ]] || { echo "${PYTHON_VERSION#v}" > .python-version; echo "CLEAN_PYTHON_VERSION=true" >> "$GITHUB_ENV"; }
56
- echo "PYTHON_VERSION=${PYTHON_VERSION}" >> "$GITHUB_ENV"
57
-
58
34
# Finding pre-commit
59
35
# This will set an environment variable we can use to conditionally
60
36
# install pre-commit if needed and toggle how the action runs.
@@ -70,14 +46,15 @@ runs:
70
46
# Only run this if we don't already have a pre-commit on the PATH
71
47
if : env.PYTHON_BIN == null && env.PRE_COMMIT_BIN == null && steps.pre-commit-config.outputs.exists != 'false'
72
48
uses : actions/setup-python@v5
49
+ - name : Setup node
50
+ uses : actions/setup-node@v4
73
51
with :
74
- python-version : ${{ env.PYTHON_VERSION }}
75
- - name : Install tools
76
- # This will skip the (slow) pyenv install if we triggered the above
77
- uses : open-turo/action-setup-tools@v1
52
+ # Default to node 20 but use the .node-version file if it exists in the consumer repo
53
+ node-version : " 20"
54
+ node-version-file : .node-version
78
55
- name : Commitlint
79
56
# This version needs to be sync'd with the repo HEAD if a major version is cut
80
- uses : open-turo/action-pre-commit/commitlint@v2
57
+ uses : open-turo/action-pre-commit/commitlint@f/make_action_pre_commit_faster
81
58
with :
82
59
restore-config : " false"
83
60
config-file : ${{ inputs.config-file }}
@@ -98,21 +75,14 @@ runs:
98
75
- name : Pre-commit (action)
99
76
# Same as above, this will install and run pre-commit for us
100
77
if : env.PRE_COMMIT_BIN == null && steps.pre-commit-config.outputs.exists != 'false'
101
- uses : pre-commit/action@v3.0.0
78
+ uses : pre-commit/action@v3.0.1
102
79
with :
103
80
extra_args : ${{ env.PRE_COMMIT_ARGS }}
104
81
- name : Pre-commit (from PATH)
105
82
# Run pre-commit directly if we found it on the PATH
106
83
if : env.PRE_COMMIT_BIN != null && steps.pre-commit-config.outputs.exists != 'false'
107
84
shell : bash
108
85
run : pre-commit run --show-diff-on-failure --color=always ${{ env.PRE_COMMIT_ARGS }}
109
- - name : Clean up version files
110
- if : always()
111
- shell : bash
112
- run : |
113
- # Clean up version files if we wrote them
114
- [[ "${{ env.CLEAN_PYTHON_VERSION }}" == "" ]] || rm .python-version
115
- [[ "${{ env.CLEAN_NODE_VERSION }}" == "" ]] || rm .node-version
116
86
- name : Restore commitlint config
117
87
if : always() && hashFiles(inputs.config-file) != '' && inputs.turo-conventional-commit == 'true'
118
88
shell : bash
0 commit comments