-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (61 loc) · 2.09 KB
/
build-deploy.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
name: Build and Deploy
on:
push:
branches:
- 'main'
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'gradle'
- uses: gradle/gradle-build-action@v2
with:
arguments: build
- name: Post build failures to Slack
if: failure()
run: |
curl -X POST --data "{\"text\": \"Build av $GITHUB_REPOSITORY feilet - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"}" $WEBHOOK_URL
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set release tag
run: |
export TAG_NAME="$(TZ="Europe/Oslo" date +%Y.%m.%d-%H.%M).$(git rev-parse --short=12 HEAD)"
echo "RELEASE_TAG=$TAG_NAME" >> $GITHUB_ENV
#- name: Set changelog
# id: changelog
# # (Escape newlines see https://github.com/actions/create-release/issues/25)
# run: |
# text="$(git --no-pager log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")"
# echo "::set-output name=CHANGELOG::$text"
- name: Create release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ env.RELEASE_TAG }}
tag_name: ${{ env.RELEASE_TAG }}
draft: false
prerelease: false
- name: Publish
uses: gradle/gradle-build-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
arguments: -Pversion=${{ env.RELEASE_TAG }} publish
- name: Post release failures to Slack
if: failure()
run: |
curl -X POST --data "{\"text\": \"Release av $GITHUB_REPOSITORY feilet - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"}" $WEBHOOK_URL
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}