-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (75 loc) · 3.07 KB
/
Copy path_pre-commit.yml
File metadata and controls
86 lines (75 loc) · 3.07 KB
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
name: 10 🛂 pre-commit
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
concurrency:
group: pre-commit-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-24.04
timeout-minutes: 30
env:
PRE_COMMIT_IMAGE: ghcr.io/antonbabenko/pre-commit-terraform:v1.105.0@sha256:4ef4b8323b27fc263535ad88c9d2f20488fcb3b520258e5e7f0553ed5f6692b5 # pre-commit-terraform v1.105.0
PRE_COMMIT_CONFIG: .pre-commit-config.yaml
# Local-only validation: Terraform must not reach remote backends.
TF_INPUT: "0"
TF_IN_AUTOMATION: "1"
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # actions/checkout@v6.0.3 release: https://github.com/actions/checkout/releases/tag/v6.0.3
with:
persist-credentials: false
- name: Restore pre-commit cache
id: pre-commit-cache
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 release: https://github.com/actions/cache/releases/tag/v5.0.5
with:
path: ${{ runner.temp }}/pre-commit-cache
key: pre-commit-${{ runner.os }}-config-hash-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-config-hash-
- name: Ensure pre-commit cache directory
env:
PRE_COMMIT_CACHE_DIR: ${{ runner.temp }}/pre-commit-cache
run: |
mkdir -p "${PRE_COMMIT_CACHE_DIR}"
- name: Pull pre-commit container image
run: |
docker pull "${PRE_COMMIT_IMAGE}"
- name: Show bundled tool versions
run: |
docker run --rm --entrypoint cat "${PRE_COMMIT_IMAGE}" /usr/bin/tools_versions_info
- name: Run pre-commit in container
id: pre-commit-run
env:
PRE_COMMIT_CACHE_DIR: ${{ runner.temp }}/pre-commit-cache
run: |
docker run --rm \
-e USERID="$(id -u):$(id -g)" \
-e PRE_COMMIT_HOME=/pre-commit-cache \
-e TF_INPUT \
-e TF_IN_AUTOMATION \
-v "${PRE_COMMIT_CACHE_DIR}:/pre-commit-cache" \
-v "${PWD}:/lint" \
-w /lint \
"${PRE_COMMIT_IMAGE}" run \
--all-files \
--config "${PRE_COMMIT_CONFIG}" \
--verbose \
--show-diff-on-failure \
--color always
- name: Save pre-commit cache
if: ${{ always() && steps.pre-commit-run.outcome != 'skipped' && steps.pre-commit-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 release: https://github.com/actions/cache/releases/tag/v5.0.5
with:
path: ${{ runner.temp }}/pre-commit-cache
key: pre-commit-${{ runner.os }}-config-hash-${{ hashFiles('.pre-commit-config.yaml') }}