-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathaction.yml
More file actions
148 lines (138 loc) · 5.26 KB
/
Copy pathaction.yml
File metadata and controls
148 lines (138 loc) · 5.26 KB
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: "Generate Roq Site"
description: "Sets up JDK, builds the Roq site, and uploads the artifact. To be used by a separate deploy step (e.g. actions/deploy-pages)."
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"
required: false
site-draft:
description: "Generate draft posts"
required: false
runs:
using: "composite"
steps:
# Step 1: Set up Java
- name: Set up Java
if: ${{ inputs.setup-java == 'true' }}
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v5
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
if [ -n "$SITE_URL" ]; then
echo "SITE_URL=$SITE_URL" >> $GITHUB_ENV
fi
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 }}
MAVEN_CMD="${{ inputs.maven-executable }} -B package quarkus:run \
${{ inputs.maven-build-args }} \
-Dquarkus.http.root-path=${{ env.SITE_PATH }}"
# Only override site.url if explicitly provided or resolved from GitHub Pages
if [ -n "${{ env.SITE_URL }}" ]; then
MAVEN_CMD="$MAVEN_CMD -Dsite.url=${{ env.SITE_URL }}"
fi
# Add site.future if it's set
if [ -n "${{ inputs.site-future }}" ]; then
MAVEN_CMD="$MAVEN_CMD -Dsite.future=${{ inputs.site-future }}"
fi
# Add site.draft if it's set
if [ -n "${{ inputs.site-draft }}" ]; then
MAVEN_CMD="$MAVEN_CMD -Dsite.draft=${{ inputs.site-draft }}"
fi
# Run Maven build with the generated arguments
$MAVEN_CMD
env:
QUARKUS_ROQ_GENERATOR_BATCH: true
# Step 5: Setup GitHub Pages
- name: Setup Pages
if: ${{ inputs.github-pages == 'true' }}
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6
# Step 6: Upload Artifact to GitHub Pages
- name: Upload Artifact
if: ${{ inputs.github-pages == 'true' }}
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5
with:
path: ${{ env.SITE_DIR }}${{ inputs.artifact-path }}