-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathaction.yml
More file actions
56 lines (53 loc) · 1.81 KB
/
Copy pathaction.yml
File metadata and controls
56 lines (53 loc) · 1.81 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
name: Run `prettier` on a branch
description: This action runs `prettier` on a branch.
inputs:
branch:
description: Name of branch to checkout and write changes to.
required: true
path:
default: docs/sources
description: Path to run `prettier` on.
required: false
token:
default: ""
description: Used to open the PR.
required: false
runs:
using: composite
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
ref: ${{ inputs.branch }}
# Use github.token since that can usually always read the repository contents.
token: ${{ github.token }}
- id: app-token
if: inputs.token == ''
uses: grafana/shared-workflows/actions/create-github-app-token@46f48da11e78ebdba7a8747ae456b11062fac83e # create-github-app-token/v0.3.1
with:
github_app: docs-platform-team
- id: prettier
env:
PRETTIER_PATH: ${{ inputs.path }}
run: |
set -euf -o pipefail
if [[ -n "${RUNNER_DEBUG+x}" ]]; then
set -x
fi
npx prettier -w "${PRETTIER_PATH}"
if git diff --quiet; then
echo "changed=false" >> "${GITHUB_OUTPUT}"
else
echo "changed=true" >> "${GITHUB_OUTPUT}"
fi
shell: bash
- name: Create signed commit
if: steps.prettier.outputs.changed == 'true'
uses: planetscale/ghcommit-action@a6b150b81dca5dd027baa898604418eec9e11465 # v0.2.22
env:
# Use App token if present because the github.token doesn't trigger other workflows like CI for pull requests.
GITHUB_TOKEN: ${{ steps.app-token.outputs.token || github.token }}
with:
commit_message: Run `prettier`
repo: ${{ github.repository }}
branch: ${{ inputs.branch }}