-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
60 lines (55 loc) · 2.09 KB
/
action.yaml
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
name: 'Yarn upgrade'
description: 'Runs a yarn upgrade'
inputs:
working-dir:
description: 'Directory of the yarn.lock'
required: true
default: './'
outputs:
diff:
description: "Script output with the changed versions"
value: ${{ steps.get-diff.outputs.diff }}
outdated:
description: "Script output with the outdated packages that are left after updating"
value: ${{ steps.get-post-update-outdated.outputs.outdated }}
runs:
using: "composite"
steps:
- name: Install outdated tool
shell: bash
run: |
npm install -g check-outdated
- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working-dir }}
run: yarn install --immutable
- name: Check pre update outdated
shell: bash
working-directory: ${{ inputs.working-dir }}
run: |
set +e
$( check-outdated --depth 1000 --ignore-dev-dependencies --columns name,current,latest,changes > ${{ runner.temp }}/pre-update ) || true
- name: Upgrade dependencies
shell: bash
working-directory: ${{ inputs.working-dir }}
run: yarn up
- name: Check yarn outdated
shell: bash
working-directory: ${{ inputs.working-dir }}
id: get-post-update-outdated
run: |
set +e
$( check-outdated --depth 1000 --ignore-dev-dependencies --columns name,current,latest,changes > ${{ runner.temp }}/post-update ) || true
echo "outdated=$(cat ${{ runner.temp }}/post-update)" >> $GITHUB_OUTPUT
- name: Make diff
shell: bash
id: get-diff
# strip ansi colors and fix line breaks
run: |
pre=$(cat ${{ runner.temp }}/pre-update | sed '1,5d' | head -n -6 | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | sed -r "s/\\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" )
post=$(cat ${{ runner.temp }}/post-update | sed '1,5d' | head -n -6 | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | sed -r "s/\\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" )
diff=$(comm <(echo "$pre") <(echo "$post") -23)
diff="${diff//'%'/'%25'}"
diff="${diff//$'\n'/'%0A'}"
diff="${diff//$'\r'/'%0D'}"
echo "diff=$diff" >> $GITHUB_OUTPUT