-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(readme) Add workflow to automatically update readme on master. Use…
…ful when just merging from develop to always show the latest release version
- Loading branch information
1 parent
7b54938
commit befbabf
Showing
2 changed files
with
155 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
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" | ||
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) | ||
echo "::set-output name=version::$LATEST_RELEASE" | ||
- name: "Generate README.adoc" | ||
run: | ||
./mvnw install | ||
-DskipTests=true | ||
-Dmaven.javadoc.skip=true | ||
-Dreadme.skip=false | ||
-DdocOghamVersion=${{ steps.latest-release.version}} | ||
-Dgit.branch=master | ||
- name: "Has changed" | ||
id: has-changed | ||
run: | | ||
CHANGED=$(git status --porcelain | grep README.adoc && echo 'true' || echo 'false') | ||
echo "::set-output name=changed::$CHANGED" | ||
- name: "Update README" | ||
run: | | ||
if [ "${{ steps.has-changed.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.version}}) on master" | ||
git push | ||
slack-updated: | ||
if: success() && fromJson(needs.update-readme.outputs.changed) | ||
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 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 }} | ||
|
||
|
Oops, something went wrong.