-
-
Notifications
You must be signed in to change notification settings - Fork 3
131 lines (107 loc) · 3.83 KB
/
main.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
name: Build, Test and Deploy
on:
push:
paths:
- 'com.developer.nefarious.zjoule.feature/**'
- 'com.developer.nefarious.zjoule.plugin/**'
- 'com.developer.nefarious.zjoule.test/**'
- 'com.developer.nefarious.zjoule.updatesite/**'
permissions:
contents: write
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven Wrapper
run: ./mvnw clean verify
release:
needs: test
if: "!contains(github.event.head_commit.message, 'skip ci') && github.ref == 'refs/heads/main'"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 18
- name: Install semantic-release
run: |
npm install -g semantic-release \
@semantic-release/changelog \
@semantic-release/commit-analyzer \
@semantic-release/exec \
@semantic-release/git \
@semantic-release/release-notes-generator
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.NEFARIOUS_GITHUB_TOKEN }}
run: chmod +x ./scripts/prepare-release.sh && npx semantic-release
update-website:
needs: release
if: "!contains(github.event.head_commit.message, 'skip ci') && github.ref == 'refs/heads/main'"
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.NEFARIOUS_GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get the latest release tag
id: get_release
run: |
LATEST_TAG=$(gh release view --json tagName -q ".tagName")
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Configure Git
run: |
git config --global user.name "nefarious-developer-bot"
git config --global user.email "nefarious-developer-bot@users.noreply.github.com"
- name: Clone the target repository
run: |
git clone https://nefarious-developer-bot:${GH_TOKEN}@github.com/The-Nefarious-Developer/zjoule-website.git website-repo
- name: Create a new branch
working-directory: website-repo
run: |
git checkout -b update-to-$LATEST_TAG
- name: Run the script to update the website
working-directory: website-repo
run: |
chmod +x ../scripts/update-website.sh
../scripts/update-website.sh $LATEST_TAG
- name: Commit the changes
working-directory: website-repo
run: |
git add .
git commit -m "feat: update to $LATEST_TAG"
- name: Push the changes
working-directory: website-repo
run: |
git push https://nefarious-developer-bot:${GH_TOKEN}@github.com/The-Nefarious-Developer/zjoule-website.git update-to-$LATEST_TAG
- name: Create a pull request
working-directory: website-repo
run: |
gh pr create \
--title "Update to $LATEST_TAG" \
--body "This PR updates the website to the latest release $LATEST_TAG." \
--head update-to-$LATEST_TAG \
--base main
- name: Automatically merge the pull request
working-directory: website-repo
run: |
PR_URL=$(gh pr view update-to-$LATEST_TAG --json url -q ".url")
gh pr merge $PR_URL --squash --admin --delete-branch