-
Notifications
You must be signed in to change notification settings - Fork 10
117 lines (96 loc) · 3.32 KB
/
preflight.yml
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
107
108
109
110
111
112
113
114
115
116
117
name: Preflight
on:
pull_request:
defaults:
run:
shell: bash
jobs:
check-commit-message:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check commit message
run: |
errors=
readarray -t long_lines < \
<(git log -1 --pretty=format:%B ${{ github.event.pull_request.head.sha }} | grep -E '^.{73,}$')
if [[ ${#long_lines[@]} -ne 0 ]]; then
printf "ERROR: The following lines are longer than 72 characters:\n"
printf " > %s\n" "${long_lines[@]}"
errors=true
fi
if [[ $errors == true ]]; then
exit 2
fi
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Get UID and GID
id: get-id
run: printf "%s\n" uid=$(id -u) gid=$(id -g) >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
# https://github.com/marketplace/actions/build-and-push-docker-images
uses: docker/build-push-action@v5
id: docker
with:
context: .
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
UID=${{ steps.get-id.outputs.uid }}
GID=${{ steps.get-id.outputs.gid }}
- name: Run build
run: |
docker run --rm -v .:/home/albs/code ${{ steps.docker.outputs.imageid }} \
npm run build
prettier:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Get changed files
# https://github.com/marketplace/actions/paths-changes-filter
uses: dorny/paths-filter@v3
id: changed-files
with:
list-files: shell
filters: |
src:
- added|modified: 'src/**/*.vue'
- added|modified: 'src/**/*.js'
- name: Get UID and GID
if: ${{ steps.changed-files.outputs.src == 'true' }}
id: get-id
run: printf "%s\n" uid=$(id -u) gid=$(id -g) >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx
uses: docker/setup-buildx-action@v3
if: ${{ steps.changed-files.outputs.src == 'true' }}
- name: Build Docker image
# https://github.com/marketplace/actions/build-and-push-docker-images
uses: docker/build-push-action@v5
if: ${{ steps.changed-files.outputs.src == 'true' }}
id: docker
with:
context: .
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
UID=${{ steps.get-id.outputs.uid }}
GID=${{ steps.get-id.outputs.gid }}
- name: Run prettier
if: ${{ steps.changed-files.outputs.src == 'true' }}
run: |
docker run --rm -v .:/home/albs/code ${{ steps.docker.outputs.imageid }} \
npx prettier --write ${{ steps.changed-files.outputs.src_files }}
git -c color.ui=always diff --exit-code