generated from softwaremill/sbt-template
-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (92 loc) · 3.19 KB
/
ci.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
name: CI
on:
pull_request:
branches: ['**']
push:
branches: ['**']
tags: [v*]
jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: srvaroa/labeler@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
output:
runs-on: ubuntu-latest
steps:
- id: sets-a-secret
name: Generate, mask, and output a secret
run: |
the_secret=$((RANDOM))
echo "::add-mask::$the_secret"
echo "secret-number=$the_secret" >> "$GITHUB_OUTPUT"
- name: Use that secret output (protected by a mask)
run: |
echo "the secret number is ${{ steps.sets-a-secret.outputs.secret-number }}"
auto-merge:
name: Auto merge
runs-on: ubuntu-20.04
steps:
- name: View PR author
run: echo "This PR is opened by ${{ github.event.pull_request.user.login }} ."
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get changes
run: git diff --name-only ${{ github.event.before }} ${{ github.event.after }}
auto-merge-2:
name: Auto merge 2
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Get changed files
id: changed-files
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
else
echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
fi
- name: List changed files
run: |
for file in ${{ steps.changed-files.outputs.changed_files }}; do
echo "$file was changed"
done
ci:
# run on external PRs, but not on internal PRs since those will be run by push to branch
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-20.04
steps:
- name: View PR author
run: echo "------- This PR is opened by ${{ github.event.pull_request.user.login }}."
- name: View PR author
run: echo "This PR is opened by ${{ github.event.pull_request.user.login }} ."
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier
key: sbt-cache-${{ runner.os }}-${{ hashFiles('project/build.properties') }}
- name: Compile
run: sbt -v compile
- name: Test
run: sbt -v test
- name: Cleanup
run: |
rm -rf "$HOME/.ivy2/local" || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "*-LM-SNAPSHOT*" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true