-
Notifications
You must be signed in to change notification settings - Fork 13
/
action.yml
133 lines (127 loc) · 4.6 KB
/
action.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
name: "Build and Deploy Roq Site"
description: "Sets up JDK, builds the Quarkus site, and upload the GitHub Pages artifact."
branding:
icon: 'music'
color: 'orange'
inputs:
setup-java:
description: "Whether to setup Java or not"
required: false
default: 'true'
java-version:
description: "Java version to use for the build"
required: false
default: "21"
java-distribution:
description: "Java distribution to use"
required: false
default: "temurin"
maven-executable:
description: 'Choose whether to use mvn or ./mvnw'
required: false
default: './mvnw'
maven-cache:
description: "Maven cache strategy"
required: false
default: "maven"
site-directory:
description: "The directory containing the Roq site"
required: false
default: "./"
maven-build-args:
description: "Additional Maven build arguments"
required: false
default: "-DskipTests"
github-pages:
description: "Whether to configure and Upload GitHub Pages artifact or not"
default: 'true'
required: false
github-token:
description: "GitHub token for accessing GitHub Pages url (required if github-pages)"
required: false
site-url:
description: "The full URL of the site including the eventual root path"
required: false
artifact-path:
description: "Path of the artifact to upload (from the site-directory)"
required: false
default: "target/roq"
site-future:
description: "Generate future posts"
default: 'false'
required: false
site-draft:
description: "Generate draft posts"
default: 'false'
required: false
runs:
using: "composite"
steps:
# Step 1: Set up Java
- name: Set up Java
if: ${{ inputs.setup-java == 'true' }}
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java-version }}
distribution: ${{ inputs.java-distribution }}
cache: ${{ inputs.maven-cache }}
# Step 2: Get GitHub Pages URL (if not provided as input)
- name: Get GitHub Pages URL
shell: bash
if: ${{ inputs.github-pages == 'true' && inputs.site-url == null }}
id: get_url
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
run: |
# Fetch GitHub Pages URL
url=$(gh api "repos/$GITHUB_REPOSITORY/pages" --jq '.html_url' 2>/dev/null || echo '')
# Check if URL is starts with http
if [[ $url == http* ]]; then
echo "GitHub Pages is enabled for this repository: $url"
echo "SITE_FULL_URL=$url" >> $GITHUB_ENV
else
echo "::error::GitHub Pages is not enabled for this repository. To enable GitHub Pages: Go to 'Settings' > 'Pages' in your repository and configure GitHub Pages."
exit 1
fi
# Step 3: Setting environments for the build
- name: Setting envs
shell: bash
run: |
FULL_URL=${{ inputs.site-url || env.SITE_FULL_URL || '/' }}
if [[ "$FULL_URL" =~ ^https?:// ]]; then
SITE_URL=$(echo "$FULL_URL" | sed -E 's|(https?://[^/]+).*|\1|') # Extract base URL
SITE_PATH=$(echo "$FULL_URL" | sed -E 's|https?://[^/]+||') # Extract path
[[ -z "$SITE_PATH" ]] && SITE_PATH="/" # Default to "/" if no path
else
SITE_URL=""
SITE_PATH="${FULL_URL:-/}" # Use input as SITE_PATH or default to "/"
fi
SITE_DIR=${{ inputs.site-directory }}
SITE_DIR=${SITE_DIR%/}/
echo "SITE_DIR=$SITE_DIR" >> $GITHUB_ENV
echo "SITE_URL=$SITE_URL" >> $GITHUB_ENV
echo "SITE_PATH=$SITE_PATH" >> $GITHUB_ENV
echo "Using SITE_DIR=$SITE_DIR, SITE_URL=$SITE_URL, SITE_PATH=$SITE_PATH"
# Step 4: Build and Generate Quarkus Blog with Quarkus HTTP Root Path
- name: Build & Generate Blog
shell: bash
run: |
cd ${{ env.SITE_DIR }}
${{ inputs.maven-executable }} -B package quarkus:run \
${{ inputs.maven-build-args }} \
-Dquarkus.http.root-path=${{ env.SITE_PATH }} \
-Dsite.url=${{ env.SITE_URL }} \
-Dsite.future=${{ inputs.site-future }} \
-Dsite.draft=${{ inputs.site-draft }}
env:
QUARKUS_ROQ_GENERATOR_BATCH: true
# Step 5: Setup GitHub Pages
- name: Setup Pages
if: ${{ inputs.github-pages == 'true' }}
uses: actions/configure-pages@v5
# Step 6: Upload Artifact to GitHub Pages
- name: Upload Artifact
if: ${{ inputs.github-pages == 'true' }}
uses: actions/upload-pages-artifact@v3
with:
path: ${{ env.SITE_DIR }}${{ inputs.artifact-path }}