-
Notifications
You must be signed in to change notification settings - Fork 15
98 lines (92 loc) · 3.13 KB
/
update-readme.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
name: Update readme on master
on:
push:
branches:
- 'master'
jobs:
update-readme:
runs-on: ubuntu-18.04
name: "Update readme on master to latest release"
outputs:
updated: ${{ steps.has-changed.outputs.changed }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-java@v1
with:
java-version: 8
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/fr/sii/
key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ secrets.CACHE_VERSION }}
- name: "Get latest release"
id: latest-release
run: |
LATEST_RELEASE="$(git tag -l | sort -Vr | head -n1)"
LATEST_RELEASE="${LATEST_RELEASE#v}"
echo "::set-output name=version::$LATEST_RELEASE"
- name: "Generate README.adoc"
run:
./mvnw install
-DskipTests=true
-Dmaven.javadoc.skip=true
-Dreadme.skip=false
-Ddoc.ogham.version=${{ steps.latest-release.outputs.version}}
-Dgit.branch=master
- name: "Has changed"
id: has-changed
run: |
CHANGED=$((git status --porcelain | grep -q README.adoc) && echo 'true' || echo 'false')
echo "CHANGED=$CHANGED"
echo "::set-output name=changed::$CHANGED"
- name: "Update README"
run: |
if [ "${{ steps.has-changed.outputs.changed }}" != "true" ]; then
echo "README already up-to-date"
exit 0
fi
echo "::warning ::Need to update README"
git config user.email [email protected]
git config user.name github-actions
git add .
git commit -m "doc(readme) Update README to always show latest release version (${{ steps.latest-release.outputs.version}}) on master"
git push
slack-updated:
if: success() && fromJson(needs.update-readme.outputs.updated)
needs: [update-readme]
runs-on: ubuntu-18.04
name: "Slack"
steps:
- uses: 8398a7/action-slack@v3
with:
status: success
fields: workflow,ref
username: 'readme'
author_name: ''
icon_url: https://github.com/groupe-sii/ogham/raw/master/src/site/resources/img/ogham-blue-256x256.png
text: |
:x: readme has been updated on master
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
slack-failure:
if: failure()
needs: [update-readme]
runs-on: ubuntu-18.04
name: "Slack"
steps:
- uses: 8398a7/action-slack@v3
with:
status: failure
fields: workflow,ref
username: 'readme'
author_name: ''
icon_url: https://github.com/groupe-sii/ogham/raw/master/src/site/resources/img/ogham-blue-256x256.png
text: |
:x: failed to update readme on master
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}