Update Javadoc #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 gh-pages branch | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- 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: Copy Javadoc to /docs directory | |
run: | | |
if [ -d "processing4/build/javadoc/core" ]; then | |
cp -r processing4/build/javadoc/core ../docs/ | |
fi | |
- name: Clean up the processing4 directory | |
run: | | |
rm -rf processing4/ | |
commit-javadoc: | |
runs-on: ubuntu-latest | |
needs: build-javadoc | |
steps: | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v3 | |
with: | |
repository: processing/processing4-javadocs | |
ref: gh-pages | |
fetch-depth: 0 | |
- name: Commit and Push changes to gh-pages if any changes exist | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
if [ -n "$(git status --porcelain docs/)" ]; then | |
git add docs/ | |
git commit -m "Update Javadocs" | |
git push https://[email protected]/processing/processing4-javadocs.git HEAD:gh-pages | |
else | |
echo "No changes to commit." | |
fi | |
env: | |
PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | |
deploy-javadoc: | |
runs-on: ubuntu-latest | |
needs: commit-javadoc | |
steps: | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v3 | |
with: | |
repository: processing/processing4-javadocs | |
ref: gh-pages | |
fetch-depth: 0 | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./docs |