Deploy a MkDocs site to GitHub Pages via GitHub Actions
The following GitHub Action workflow to build and deploy the site to GitHub Pages gh-pages
branch:
name: Publish
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: ⚙️ Install dependencies
run: |
python -m pip install --upgrade pip
pip install mkdocs
- name: 🏗️ Build Site
run: mkdocs build
- name: 🚀 Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site
PageSpeed Insights
PageSpeed Insights (PSI) reports on the user experience of a page on both mobile and desktop devices, and provides suggestions on how that page may be improved.
Being a Google Service, it may soon be killed by Google
Hosting a static website in GitHub Pages and Hover
In this blog post, I show you how to host a website in GitHub Pages and manage the domain with Hover
Website
I recently joined a local chess association in Guadalajara. They did not have a website, so I offered to create one for them. The website is a static website with HTML and Bootstrap.
The website is simple, but it conveys the association information, and it scores 100% in performance, accessibility, best practices and SEO.
GitHub Organization
Instead of creating it from my personal account, I created a GitHub Organization dedicated to the association. I verified the domain at the GitHub Organization level. You need to verify the domain at the organizational level, not the repository level.
GitHub Pages
Micronaut publishes its documentation to GitHub Pages deploying from branch gh-pages
. For this website, I used GitHub Actions as the source instead. The website changes seem remarkably faster.
GitHub Action Workflow
The following GitHub Action workflow deploys the contents of the dist
folder.
name: Deploy static content to Pages
on:
push:
branches: ["main"]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Domain
I use Hover as a domain registrar. I use the following DNS configuration as pointed out by GitHub Pages documentation.
TYPE | HOST | VALUE | TTL |
---|---|---|---|
A | @ | 185.199.109.153 | 15 Minutes |
A | @ | 185.199.110.153 | 15 Minutes |
A | @ | 185.199.111.153 | 15 Minutes |
A | @ | 185.199.108.153 | 15 Minutes |
AAAA | @ | 2606:50c0:8000::153 | 15 Minutes |
AAAA | @ | 2606:50c0:8001::153 | 15 Minutes |
AAAA | @ | 2606:50c0:8002::153 | 15 Minutes |
AAAA | @ | 2606:50c0:8003::153 | 15 Minutes |
TXT | _github-pages-challenge-ajedrezcallejeroguadalajara | 89676ddaaeb7a6adec23d364020599 | 15 Minutes |
CNAME | www | ajedrezcallejeroguadalajara.github.io | 15 Minutes |
Cost
The total cost for the association is 18 USD per year - the cost of the domain.
Summary
I hope this post shows you how easy is to host a website in GitHub Pages and manage the domain with Hover.
If you are in the Guadalajara (Spain) area, I hope to play chess against you soon. You can find the meetup information at ajedrezcallejeroguadalajara.com.
MavenLocal repository only for snapshots with the Gradle Kotlin DSL
Sometimes, while developing you need to define mavenLocal() repository in a Gradle build. Gradle allows you to constraint the repository only to snapshots.
It is easy to do it with the Gradle Kotlin DSL.
repositories {
mavenCentral()
mavenLocal {
mavenContent {
snapshotsOnly()
}
}
maven {
setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots/")
mavenContent {
snapshotsOnly()
}
}
}
📼 Video of my Micronaut framework introduction talk at the JDevSummit IL conference
I did a Micronaut framework introduction in the JDevSummit IL conference.
Idempotence
An idempotent operation is defined as one which, if performed more than once, results in the same outcome.
Spring Academy Implementing POST:
An idempotent operation is defined as one which, if performed more than once, results in the same outcome. In a REST API, an idempotent operation is one that even if it were to be performed several times, the resulting data on the server would be the same as if it had been performed only once.
Micronaut framework introduction on JDevSummitIL
I will do an online talk about getting started with the Micronaut Framework at JDevSummitIL.
Create a Status Page
I do a lot of open source releases in my work.
I have a checklist to verify the necessary services are available by visiting the following status pages:
At UnityFoundation we use Basecamp. Yesterday, Basecamp was suffering a DDOS attack and I visited their status page. It uses Atlassian Statuspage. Atlassian statuspage has a free plan.
Our free plan gives you access to 100 subscribers, 25 components, two team members, two metrics, email notifications, Slack notifications, and access to REST APIs.
Atlassian statuspage is a good option if you need to set up a status page for your service.
Website Monitoring
Serveral options to monitor a website.
I have used both Pingdom and Pingability in the past.
WebJars
WebJars are client-side web libraries (e.g. jQuery & Bootstrap) packaged into JAR (Java Archive) files.
It's a clever project to get started with a Javascript library in a Java project.
English Pluralization Java library
Evo Inflector implements English pluralization algorithm based on "Damian Conway's" paper "An Algorithmic Approach to English Pluralization".
English.plural("virus") == "viruses"
📖 Micronaut Guide Asciidoc of OpenAPI
I wrote a Micronaut Tutorial that shows how to generate an OpenAPI Specification of your Micronaut Application at build time and generate it in Asciidoc format.
📖 Micronaut Guide Content Negotiation
I wrote a Micronaut tutorial which shows how to respond HTML or JSON depending on the request Accept HTTP Header.
Micronaut CRaC
Talk at JCON World 2023
Micronaut EclipseStore
Talk at JCON World 2023
Bash Script to run the same test multiple times in a Gradle build
A flaky test is a software test that yields both passing and failing results despite zero changes to the code or test
#!/bin/bash
EXIT_STATUS=0
NUM_RUNS=100
SUCCESSFUL_RUNS=0
for ((i=1; i<=$NUM_RUNS; i++)); do
./gradlew :micronaut-gcp-pubsub:test --tests io.micronaut.gcp.pubsub.integration.SubscriberShutdownSpec --rerun || EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
exit $EXIT_STATUS
fi
done
exit $EXIT_STATUS
📖 Server-side HTML with Thymeleaf and Micronaut Views
I wrote a guide that shows how to render server-side HTML with Thymeleaf and Micronaut Views.
Gradle Java Test Fixtures Plugin
Gradle Plugin which automatically create a testFixtures
source set, in which you can write your test fixtures.
Test fixtures are commonly used to setup the code under test, or provide utilities aimed at facilitating the tests of a component. Java projects can enable test fixtures support by applying the
java-test-fixtures
plugin, in addition to the java or java-library plugins.
This will automatically create a testFixtures source set, in which you can write your test fixtures. Test fixtures are configured so that:
- they can see the main source set classes
test sources can see the test fixtures classes
System Stubs
System Stubs is used to test code which depends on methods in java.lang.System.
@ExtendWith(SystemStubsExtension.class)
class WithEnvironmentVariables {
@SystemStub
private EnvironmentVariables variables = new EnvironmentVariables("input", "foo");
@Test
void hasAccessToEnvironmentVariables() {
assertThat(System.getenv("input")).isEqualTo("foo");
}
@Test
void changeEnvironmentVariablesDuringTest() {
variables.set("input", "bar");
assertThat(System.getenv("input")).isEqualTo("bar");
}
}
Micronaut Framework 4.1.3
Patch release with Core, Oracle Cloud, Serialization, Netty, and SQL updates.