-
Notifications
You must be signed in to change notification settings - Fork 28
148 lines (142 loc) · 5.38 KB
/
on-pr.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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: On Pull Request
on:
pull_request:
types: [ opened, reopened, review_requested, edited, ready_for_review, synchronize ]
paths:
- 'backend/**'
- 'frontend/**'
env:
SERVICE_NAME: gitactionboard
jobs:
determine-changes:
runs-on: ubuntu-22.04
outputs:
HAS_BACKEND_CHANGES: ${{ steps.changes.outputs.backend }}
HAS_FRONTEND_CHANGES: ${{ steps.changes.outputs.frontend }}
steps:
- name: Checkout local repository
uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/${{ env.SERVICE_NAME }}
fetch-depth: 5
- name: Determine new changes
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
working-directory: ${{ github.workspace }}/${{ env.SERVICE_NAME }}/
backend-verification:
needs: [ determine-changes ]
if: ${{ needs.determine-changes.outputs.HAS_BACKEND_CHANGES == 'true' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout local repository
uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/${{ env.SERVICE_NAME }}
- name: Install prettier using npm
run: sudo npm install --global prettier
- name: Install jenv
run: |
git clone https://github.com/gcuisinier/jenv.git ~/.jenv
echo "$HOME/.jenv/bin" >> $GITHUB_PATH
- name: Configure jenv
run: |
jenv init -
jenv add ${JAVA_HOME_21_X64}
- name: Install Hadolint and add to PATH
run: |
sh bin/install-hadolint.sh
echo "$GITHUB_WORKSPACE/$SERVICE_NAME" >> $GITHUB_PATH
working-directory: ${{ github.workspace }}/${{ env.SERVICE_NAME }}/
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash
- name: Cache gradle wrapper and jars
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-${{ steps.get-date.outputs.date }}-
${{ runner.os }}-gradle-
- name: Run tests
run: ./run.sh backend-test
working-directory: ${{ github.workspace }}/${{ env.SERVICE_NAME }}/
- name: Upload build report to artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ env.SERVICE_NAME }}-build-reports
path: ${{ github.workspace }}/${{ env.SERVICE_NAME }}/backend/build/reports/
frontend-verification:
needs: [ determine-changes ]
if: ${{ needs.determine-changes.outputs.HAS_FRONTEND_CHANGES == 'true' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout local repository
uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/${{ env.SERVICE_NAME }}
- name: Install nvm at specific version
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- name: Install prettier using npm
run: sudo npm install --global prettier
- name: Install Hadolint and add to PATH
run: |
sh bin/install-hadolint.sh
echo "$GITHUB_WORKSPACE/$SERVICE_NAME" >> $GITHUB_PATH
working-directory: ${{ github.workspace }}/${{ env.SERVICE_NAME }}/
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash
- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Run tests
run: ./run.sh frontend-test
working-directory: ${{ github.workspace }}/${{ env.SERVICE_NAME }}/
dependabot:
runs-on: ubuntu-22.04
needs: [ backend-verification, frontend-verification ]
if: ${{ always() && github.actor == 'dependabot[bot]' && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }}
permissions:
contents: write
pull-requests: write
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
run: gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Add reviewers and label for Major update
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-major'}}
run: |
gh pr edit "$PR_URL" --add-label "major-update"
gh pr edit "$PR_URL" --add-reviewer "sumanmaity1234"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}