-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
106 lines (100 loc) · 4.21 KB
/
Copy pathaction.yml
File metadata and controls
106 lines (100 loc) · 4.21 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Commit Check Action
description: Check commit message formatting, branch naming, committer name, email, and more
author: shenxianpeng
branding:
icon: "git-commit"
color: "blue"
inputs:
message:
description: check git commit message following conventional commits
required: false
default: true
branch:
description: check git branch name following conventional branch
required: false
default: true
author-name:
description: check committer author name
required: false
default: false
author-email:
description: check committer author email
required: false
default: false
dry-run:
description: report failures (summary, PR comment, annotations as warnings) but always exit 0
required: false
default: false
job-summary:
description: display job summary to the workflow run
required: false
default: true
pr-comments:
description: post results to the pull request comments
required: false
default: false
pr-title:
description: check pull request title following conventional commits
required: false
default: false
outputs:
result:
description: Structured check results as JSON (status pass/warn/skip/fail + per-scope label, sha and checks). Consume with fromJSON(steps.<id>.outputs.result).
# Composite actions do not forward step outputs automatically: without this
# mapping (and the step id it refers to) the output is always the empty
# string, and fromJSON('') fails the calling workflow.
value: ${{ steps.commit-check.outputs.result }}
runs:
using: "composite"
steps:
- name: Install dependencies and run commit-check
id: commit-check
shell: bash
run: |
# Platform-specific settings
if [[ "$RUNNER_OS" == "Windows" ]]; then
PYTHON_CMD="python"
else
if [[ "$RUNNER_OS" == "Linux" ]]; then
# https://github.com/pypa/setuptools/issues/3269
export DEB_PYTHON_INSTALL_LAYOUT=deb
fi
PYTHON_CMD="python3"
fi
# Everything the action installs lives under $RUNNER_TEMP, never in the
# caller's checkout: a later `git status`, linter or upload-artifact step
# must not see our venv or wheels.
WORK="$RUNNER_TEMP/commit-check-action"
rm -rf "$WORK" # a second invocation in the same job starts clean, so the wheel glob below matches exactly one file
mkdir -p "$WORK/wheels"
$PYTHON_CMD -m venv "$WORK/venv"
if [[ "$RUNNER_OS" == "Windows" ]]; then
source "$WORK/venv/Scripts/activate"
else
source "$WORK/venv/bin/activate"
fi
# One download of the pinned closure, into the scratch dir. Wheels only:
# the offline install below cannot build an sdist, so a platform without
# binary wheels fails here, with pip's message, rather than later.
$PYTHON_CMD -m pip download -q --only-binary=:all: -d "$WORK/wheels" -r "$GITHUB_ACTION_PATH/requirements.txt"
# Verify the commit-check wheel's build provenance (PyGithub and the
# transitive wheels are pinned but not attested; see README "Runner requirements").
WHEEL=$(ls "$WORK"/wheels/commit_check-*.whl) # exactly one: pip download of a == pin
if ! gh attestation verify "$WHEEL" -R commit-check/commit-check; then
echo "::error::Attestation verification failed for $(basename "$WHEEL") (self-hosted runners need the gh CLI). Aborting installation."
exit 1
fi
# Install offline from the wheels we already downloaded and verified:
# no second trip to PyPI, and the installed set is exactly the downloaded set.
$PYTHON_CMD -m pip install -q --no-cache-dir --no-index --find-links "$WORK/wheels" -r "$GITHUB_ACTION_PATH/requirements.txt"
$PYTHON_CMD "$GITHUB_ACTION_PATH/main.py"
env:
MESSAGE: ${{ inputs.message }}
BRANCH: ${{ inputs.branch }}
AUTHOR_NAME: ${{ inputs.author-name }}
AUTHOR_EMAIL: ${{ inputs.author-email }}
DRY_RUN: ${{ inputs.dry-run }}
JOB_SUMMARY: ${{ inputs.job-summary }}
PR_COMMENTS: ${{ inputs.pr-comments }}
PR_TITLE: ${{ inputs.pr-title }}
GITHUB_TOKEN: ${{ github.token }}