Add CORS support; turn down logging on methods (#236) #77
Workflow file for this run
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: Maven Release | |
# Deploy the webrepl when a new tag is pushed | |
on: | |
push: | |
tags: [ 'webrepl-*' ] | |
jobs: | |
release: | |
name: Maven PR Builder (JDK ${{ matrix.java }}) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ "21" ] | |
maven: [ "3.8.2" ] | |
jdk: [ "temurin" ] | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 | |
with: | |
platforms: all | |
- name: Set up Docker | |
if: ${{ !env.ACT || env.ACT == '' }} | |
uses: crazy-max/ghaction-setup-docker@26145a578dce008fee793528d031cd72c57d51af # v3.4.0 | |
with: | |
set-host: true | |
daemon-config: | | |
{ | |
"debug": true, | |
"features": { | |
"containerd-snapshotter": true | |
} | |
} | |
- name: Login to Docker repository | |
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Install JDK ${{ matrix.java }} | |
uses: actions/setup-java@860f60056505705214d223b91ed7a30f173f6142 # v3.3.0 | |
with: | |
cache: maven | |
distribution: ${{ matrix.jdk }} | |
java-version: ${{ matrix.java }} | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
- name: Set release version | |
shell: bash | |
run: | | |
GITHUB_REF="${{ github.ref }}" && | |
TAG_NAME="${GITHUB_REF#refs/tags/}" && | |
echo "RELEASE_VERSION=${TAG_NAME#webrepl-}" >> $GITHUB_ENV | |
- name: Set up Maven if needed | |
if: ${{ env.ACT }} | |
uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f # v4.5 | |
with: | |
maven-version: ${{ matrix.maven }} | |
# The following two steps could be removed once the latest v3 is in Maven Central, but | |
# it might be nice to allow snapshots in the POM still as an option to support testing | |
- name: Download JPv3 | |
env: | |
JPV3_URL: ksclarke.nyc3.digitaloceanspaces.com | |
run: | | |
curl -s --output-dir /tmp -O "https://${{ env.JPV3_URL }}/jiiify-presentation-v3-0.0.0-SNAPSHOT.jar" | |
- name: Install JPv3 | |
run: | | |
mvn install:install-file -Dfile=/tmp/jiiify-presentation-v3-0.0.0-SNAPSHOT.jar -Dpackaging=jar \ | |
-DgroupId=info.freelibrary -DartifactId=jiiify-presentation-v3 -Dversion=0.0.0-SNAPSHOT | |
- name: Release with Maven | |
env: | |
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.BUILD_PASSPHRASE }} | |
MAVEN_GPG_KEY: ${{ secrets.BUILD_KEY }} | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
DOCKER_ACCOUNT: ${{ secrets.DOCKER_ACCOUNT }} | |
DOCKER_BUILDKIT: 1 | |
run: | | |
mvn -B -ntp deploy -Prelease -Drevision="${{ env.RELEASE_VERSION }}" -DskipNexusStagingDeployMojo="true" \ | |
-Ddocker.sbom=true -Ddocker.provenance=true | |
deploy: | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Set release version | |
shell: bash | |
run: | | |
GITHUB_REF="${{ github.ref }}" && | |
TAG_NAME="${GITHUB_REF#refs/tags/}" && | |
echo "REPO_OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV && | |
echo "ARTIFACT_NAME=jpv3-${TAG_NAME%%-*}" >> $GITHUB_ENV && | |
echo "RELEASE_VERSION=${TAG_NAME#webrepl-}" >> $GITHUB_ENV | |
- name: SSH to server and deploy | |
uses: appleboy/ssh-action@25ce8cbbcb08177468c7ff7ec5cbfa236f9341e1 # v1.1.0 | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
passphrase: ${{ secrets.SSH_KEY_PASSPHRASE }} | |
envs: ARTIFACT_NAME,RELEASE_VERSION,REPO_OWNER | |
script: | | |
RUNNING_CONTAINER_METADATA="$(docker ps | grep -s $ARTIFACT_NAME)" | |
if [ -n "$RUNNING_CONTAINER_METADATA" ]; then | |
docker rm -f $(echo $RUNNING_CONTAINER_METADATA | cut -d' ' -f1) >/dev/null 2>&1 | |
docker rmi $(echo $RUNNING_CONTAINER_METADATA | tr -s ' ' | cut -d' ' -f2 ) >/dev/null 2>&1 | |
fi | |
docker rm -f "$ARTIFACT_NAME" >/dev/null 2>&1 | |
docker run -d --name "$ARTIFACT_NAME" -p 8888:8888 "$REPO_OWNER/$ARTIFACT_NAME:$RELEASE_VERSION" |