Skip to content

Commit

Permalink
Automate deployment of API viewer to GitHub Pages (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Mar 20, 2023
1 parent 71ce943 commit d3b2ca9
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 24 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/api-viewer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy API viewer to GitHub Pages

on:
push:
branches:
- master
workflow_dispatch:

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
contents: read
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build API viewer
run: mvn -B -V -e -ntp -Pquick-build clean verify
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./job-dsl-plugin/target/gh-pages

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
5 changes: 3 additions & 2 deletions job-dsl-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"description": "Job DSL",
"private": true,
"scripts": {
"mvnbuild": "npm run build",
"mvnbuild": "npm run build && npm run gh-pages",
"mvntest": "npm run test",
"test": "eslint --config .eslintrc.js",
"watch": "webpack --watch --config webpack.dev.js",
"start": "webpack serve --open --config webpack.dev.js",
"build": "webpack --config webpack.prod.js"
"build": "webpack --config webpack.plugin.js",
"gh-pages": "webpack --config webpack.gh-pages.js"
},
"repository": {
"type": "git",
Expand Down
17 changes: 0 additions & 17 deletions job-dsl-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@
<email>mr.sheehan@gmail.com</email>
</developer>
</developers>
<distributionManagement>
<site>
<id>github.com</id>
<url>scm:git:git@github.com:${gitHubUser}/job-dsl-plugin.git</url>
</site>
</distributionManagement>
<properties>
<gitHubUser>jenkinsci</gitHubUser>
<!-- TODO GMavenPlus does not support Javadoc -->
<maven.javadoc.skip>true</maven.javadoc.skip>
<node.version>18.14.2</node.version>
Expand Down Expand Up @@ -474,16 +467,6 @@
<compatibleSinceVersion>1.81</compatibleSinceVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<checkinComment>updated gh-pages for ${project.version}</checkinComment>
<scmBranch>gh-pages</scmBranch>
<!-- TODO create a Webpack configuration for a non-embedded site with production JS/CSS -->
</configuration>
</plugin>
</plugins>
</build>
</project>
2 changes: 0 additions & 2 deletions job-dsl-plugin/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const path = require("path");
const webpack = require("webpack");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
Expand Down Expand Up @@ -62,6 +61,5 @@ module.exports = {
assetModuleFilename: "[name].[hash][ext][query]",
clean: true,
filename: "[name].[contenthash].js",
path: path.join(__dirname, "src/main/webapp/api-viewer"),
},
};
8 changes: 6 additions & 2 deletions job-dsl-plugin/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");

module.exports = merge(common, {
mode: "development",
devtool: "inline-source-map",
devServer: {
static: "./src/main/webapp/api-viewer",
static: "target/dev-api-viewer",
},
plugins: [
new CopyPlugin({
patterns: [
{ from: "src/main/json/development/config.json" },
{ from: "src/main/json/static/config.json" },
{ from: "target/update-center.json" },
{ from: "target/versions/*.json", to: "[name][ext]" },
],
}),
],
output: {
path: path.join(__dirname, "target/dev-api-viewer"),
},
});
20 changes: 20 additions & 0 deletions job-dsl-plugin/webpack.gh-pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");

module.exports = merge(common, {
mode: "production",
plugins: [
new CopyPlugin({
patterns: [
{ from: "src/main/json/static/config.json" },
{ from: "target/update-center.json" },
{ from: "target/versions/*.json", to: "[name][ext]" },
],
}),
],
output: {
path: path.join(__dirname, "target/gh-pages"),
},
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");

module.exports = merge(common, {
mode: "production",
plugins: [
new CopyPlugin({
patterns: [
{ from: "src/main/json/production/config.json" },
{ from: "src/main/json/embedded/config.json" },
],
}),
],
output: {
path: path.join(__dirname, "src/main/webapp/api-viewer"),
},
});

0 comments on commit d3b2ca9

Please sign in to comment.