-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (114 loc) · 3.8 KB
/
build-and-deploy-javadoc.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
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
name: Update Javadoc
on:
schedule:
- cron: '0 0 * * 1' # This runs the workflow every Monday at midnight UTC
workflow_dispatch:
jobs:
fetch-latest-release:
runs-on: ubuntu-latest
env:
REPO: "processing/processing4"
steps:
- name: Get the latest release tag and commit SHA
id: get-commit-sha
run: |
# Step 1: Get the latest release tag
latest_tag=$(curl --silent "https://api.github.com/repos/${{ env.REPO }}/releases/latest" | jq -r .tag_name)
if [ -z "$latest_tag" ]; then
echo "Failed to retrieve the latest tag."
exit 1
fi
echo "Latest tag: $latest_tag"
# Step 2: Get the SHA associated with the tag
response=$(curl --silent "https://api.github.com/repos/${{ env.REPO }}/git/ref/tags/$latest_tag")
type=$(echo "$response" | jq -r '.object.type')
tag_sha=$(echo "$response" | jq -r '.object.sha')
# Step 3: Check if the tag points directly to a commit
if [ "$type" == "commit" ]; then
commit_sha="$tag_sha"
else
# If the tag points to an annotated tag, retrieve the commit SHA
commit_sha=$(curl --silent "https://api.github.com/repos/${{ env.REPO }}/git/tags/$tag_sha" | jq -r '.object.sha')
fi
echo "Commit SHA: $commit_sha"
echo "commit_sha=$commit_sha" >> $GITHUB_ENV
build-javadoc:
runs-on: ubuntu-latest
needs: fetch-latest-release
env:
REMOTE_URL: "https://github.com/processing/processing4.git"
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
- name: Ensure Ant is installed
run: |
if ! command -v ant &> /dev/null; then
echo "Ant not found, installing..."
sudo apt-get update && sudo apt-get install -y ant
else
echo "Ant is already installed"
fi
- name: Fetch and checkout the specific commit
run: |
git clone ${{ env.REMOTE_URL }} processing4
cd processing4
git checkout ${{ env.commit_sha }}
- name: Generate Javadocs
working-directory: processing4/build
run: |
ant doc
- name: Add .nojekyll file
run: echo > processing4/build/javadoc/.nojekyll
- name: Upload Javadocs artifact
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: processing4/build/javadoc
- name: Clean up the processing4 directory
run: |
rm -rf processing4/
deploy-javadoc:
needs: build-javadoc
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
artifact_name: github-pages
- name: Echo the output page URL
run: echo "Your site is live at ${{ steps.deployment.outputs.page_url }}"
commit-javadoc:
needs: build-javadoc
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Copy Javadocs to /doc folder
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
mkdir -p doc
cp -r processing4/build/javadoc/* doc/
git add doc/
if git diff-index --quiet HEAD; then
echo "No changes to commit"
else
git commit -m "Update Javadocs"
git push
fi